-
Notifications
You must be signed in to change notification settings - Fork 10
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
Integrate New User Statistics into Profile Retrieval #153
Conversation
@JGreenlee Please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good – I have a suggestion
I didn't do a great job of explaining what I was looking for since I wrote it out on my phone. Here's what I meant by my last suggestion: # Fetch data for the user, cached for repeated queries
if not profile_data:
profile_data = {}
# Assign existing profile attributes to the user dictionary
user['platform'] = profile_data.get('curr_platform')
user['manufacturer'] = profile_data.get('manufacturer')
user['app_version'] = profile_data.get('client_app_version')
user['os_version'] = profile_data.get('client_os_version')
user['phone_lang'] = profile_data.get('phone_lang')
# Assign newly stored statistics to the user dictionary
user['total_trips'] = profile_data.get('total_trips', 0)
user['labeled_trips'] = profile_data.get('labeled_trips', 0)
# Retrieve and assign pipeline range
pipeline_range = profile_data.get('pipeline_range', {})
user['pipeline_start_ts'] = pipeline_range.get('start_ts')
user['pipeline_end_ts'] = pipeline_range.get('end_ts')
# Retrieve and assign last API call timestamp
user['last_call'] = profile_data.get('last_call')
# Optional: Format the last_call timestamp for readability
if user['last_call']:
user['formatted_last_call'] = arrow.get(user['last_call']).format('YYYY-MM-DD HH:mm:ss')
else:
user['formatted_last_call'] = None
If This allows the |
@JGreenlee Addressed comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my review of e-mission/e-mission-server#993, the code looks good but I am not sure it has been tested locally.
With this PR and e-mission/e-mission-server#993, I ran the pipeline on one fresh test user. There are blank fields here, which makes sense because I did not yet access the diary. I used the Simulator to run e-mission-phone and sign into this user. After refreshing the dashboard I see this:
|
op-admin-dashboard/utils/constants.py Lines 38 to 52 in d372913
Either use the original column names or update the valid cols here. (side note, maybe rename to |
After accessing the app via the Simulator, I ran the pipeline again trying to get To debug I looked at pipeline logs to see if it was being recorded. Searching for
It is recorded as |
Note that I formatted Also note that I removed some default values, such as 0 for In scenario (i) we'd want to show the 0 value but in scenario (ii) I'd argue that a blank cell is a better choice (which is what happens if we allow it to be |
Tested via ./e-mission-py.bash bin/debug/load_timeline_for_day_and_user.py emission/tests/data/real_examples/shankari_2016-07-25 nrelop_dev-emulator-study_2
./e-mission-py.bash bin/debug/intake_single_user.py -e nrelop_dev-emulator-study_2
./e-mission-py.bash bin/debug/purge_user.py -e nrelop_dev-emulator-study_2```
On stm_ebike dump which had no uuids originally
|
@JGreenlee Ready for rereview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but depends on e-mission/e-mission-server#993 to be deployed at the same time
@TeachMeTW the change is pretty straightforward, but the commit history is not. |
**Overview** Enhances the user profile data retrieval process by incorporating newly stored statistics (`pipeline_range`, `total_trips`, `labeled_trips`, and `last_call`) into the existing `with` block. These statistics are now seamlessly integrated into the `user` dictionary, providing a more comprehensive set of user metrics for further analysis and dashboard visualization. 1. **Enhanced Profile Data Retrieval** - **Existing Functionality**: - The `with` block previously retrieved basic profile information such as `platform`, `manufacturer`, `app_version`, `os_version`, and `phone_lang` from the database and assigned them to the `user` dictionary. - **New Enhancements**: - **Pipeline Range**: - Retrieved `pipeline_range` data, including `start_ts` and `end_ts`, to understand the timeframe of the user's activity pipeline. - **Trip Counts**: - Extracted `total_trips` and `labeled_trips` to provide insights into the user's trip data and the extent of trip labeling. - **Last API Call Timestamp**: - Obtained `last_call` to track the most recent API interaction by the user. - **Optional Formatting**: - Included a formatted version of the `last_call` timestamp for better readability in reports and dashboards. 2. **Updated `with` Block Structure** - **Integration of New Statistics**: - The `with` block now not only fetches and assigns basic profile attributes but also retrieves and assigns the newly stored statistics from the database. Additional commits squashed into this: - Accidentally removed the process loop - Simplified else block for user data - Merge - Addressed comment, modified else if block - Updated COLS to be uniform like the other constants. Updated ADD USER STATS
fd32ba1
to
186fc73
Compare
The change was fairly complex to rebase because the first change commented out a bunch of code Since the commits here were interspersed with commits that had already been merged, we needed to reorder before we could squash. But reordering wouldn't work because the base for the first commit here was the old timing, and so applying the change resulted in a merge conflict. @TeachMeTW you really need to use have cleaner commits instead of pushing changes whenever you make any temporary change. In the end, the changes were simple enough that I just generated a diff, and used patch to apply it as a single commit which I then force-pushed |
Overview
Enhances the user profile data retrieval process by incorporating newly stored statistics (
pipeline_range
,total_trips
,labeled_trips
, andlast_call
) into the existingwith
block. These statistics are now seamlessly integrated into theuser
dictionary, providing a more comprehensive set of user metrics for further analysis and dashboard visualization.Changes Made
1. Enhanced Profile Data Retrieval
Existing Functionality:
with
block previously retrieved basic profile information such asplatform
,manufacturer
,app_version
,os_version
, andphone_lang
from the database and assigned them to theuser
dictionary.New Enhancements:
pipeline_range
data, includingstart_ts
andend_ts
, to understand the timeframe of the user's activity pipeline.total_trips
andlabeled_trips
to provide insights into the user's trip data and the extent of trip labeling.last_call
to track the most recent API interaction by the user.last_call
timestamp for better readability in reports and dashboards.2. Updated
with
Block StructureIntegration of New Statistics:
with
block now not only fetches and assigns basic profile attributes but also retrieves and assigns the newly stored statistics from the database.Awaiting Enhance
_get_and_store_range
Function to Include Trip Statistics and Last API Call Tracking e-mission-server#993