Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance _get_and_store_range Function to Include Trip Statistics and Last API Call Tracking #993

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TeachMeTW
Copy link
Contributor

Overview

Enhances _get_and_store_range by adding total_trips, labeled_trips, and last_call fields to the user profile, enabling better insights into user activities and API usage.

Changes

  1. Extended User Profile Updates:

    • total_trips: Total number of trips recorded for the user.
    • labeled_trips: Number of labeled/annotated trips.
  2. Integrated Last API Call Tracking:

    • Accesses stats/server_api_time to retrieve timestamps of the last GET and PUT API calls.
    • Determines the latest call and stores it as last_call in the user's profile in UNIX format.

Testing

  1. Picked a user, cleared pipeline, re-ran pipeline, verified user profile was updated.

Please review and provide feedback or approval.

@TeachMeTW
Copy link
Contributor Author

TeachMeTW commented Nov 8, 2024

Now I only have one concern: the current iteration does not use UUID in the api_call query, so I’m not too sure if the last call is accurate. If I do include the UUID, the last call is NULL for that UUID.

docs_cursor = edb.get_timeseries_db().find({
    "metadata.key": "stats/server_api_time",
    "user_id" : user_id
})

Thoughts?

emission/pipeline/intake_stage.py Outdated Show resolved Hide resolved
emission/pipeline/intake_stage.py Outdated Show resolved Hide resolved
emission/pipeline/intake_stage.py Outdated Show resolved Hide resolved
emission/pipeline/intake_stage.py Outdated Show resolved Hide resolved
@TeachMeTW
Copy link
Contributor Author

@JGreenlee Comments addressed, I split the function into a different file as suggested -- though it may be overkill. Seeking thoughts

Copy link
Contributor

@JGreenlee JGreenlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactor! I agree that the smaller functions are overkill.
Sometimes it's just a matter of finding the balance between tidiness and complexity.

emission/analysis/result/user_stat.py Outdated Show resolved Hide resolved
emission/analysis/result/user_stat.py Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

emission/analysis/result/user_stat.py Outdated Show resolved Hide resolved
emission/analysis/result/user_stat.py Show resolved Hide resolved
@TeachMeTW
Copy link
Contributor Author

@JGreenlee Comments addressed

Addressed comments, reduced overkill on refactor

Forgot to add last_call_ts
@TeachMeTW
Copy link
Contributor Author

@JGreenlee Addressed and rebased

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for review by Shankari
Development

Successfully merging this pull request may close these issues.

2 participants