Skip to content

Commit fd32ba1

Browse files
committed
Updated COLS to be uniform like the other constants. Updated ADD USER STATS
1 parent 3da0f4d commit fd32ba1

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

utils/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"inferred_section_summary",
3636
]
3737

38-
valid_uuids_columns = [
38+
VALID_UUIDS_COLS = [
3939
'user_token',
4040
'user_id',
4141
'update_ts',

utils/db_utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def process_user(user):
439439
user_uuid = UUID(user['user_id'])
440440
profile_data = edb.get_profile_db().find_one({'user_id': user_uuid})
441441
# Fetch data for the user, cached for repeated queries
442+
logging.info(f'keyspr: {profile_data}')
442443
if not profile_data:
443444
profile_data = {}
444445
# Assign existing profile attributes to the user dictionary
@@ -447,25 +448,24 @@ def process_user(user):
447448
user['app_version'] = profile_data.get('client_app_version')
448449
user['os_version'] = profile_data.get('client_os_version')
449450
user['phone_lang'] = profile_data.get('phone_lang')
450-
451451

452452
# Assign newly stored statistics to the user dictionary
453-
user['total_trips'] = profile_data.get('total_trips', 0)
454-
user['labeled_trips'] = profile_data.get('labeled_trips', 0)
453+
user['total_trips'] = profile_data.get('total_trips')
454+
user['labeled_trips'] = profile_data.get('labeled_trips')
455455

456456
# Retrieve and assign pipeline range
457457
pipeline_range = profile_data.get('pipeline_range', {})
458-
user['pipeline_start_ts'] = pipeline_range.get('start_ts')
459-
user['pipeline_end_ts'] = pipeline_range.get('end_ts')
458+
start_ts = pipeline_range.get('start_ts')
459+
end_ts = pipeline_range.get('end_ts')
460+
if start_ts:
461+
user['first_trip'] = arrow.get(start_ts).format(time_format)
462+
if end_ts:
463+
user['last_trip'] = arrow.get(end_ts).format(time_format)
460464

461465
# Retrieve and assign last API call timestamp
462-
user['last_call'] = profile_data.get('last_call')
463-
464-
# Optional: Format the last_call timestamp for readability
465-
if user['last_call']:
466-
user['formatted_last_call'] = arrow.get(user['last_call']).format('YYYY-MM-DD HH:mm:ss')
467-
else:
468-
user['formatted_last_call'] = None
466+
last_call_ts = profile_data.get('last_call_ts')
467+
if last_call_ts:
468+
user['last_call'] = arrow.get(last_call_ts).format('YYYY-MM-DD')
469469

470470
esdsq.store_dashboard_time(
471471
"admin/db_utils/add_user_stats/process_user",

utils/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_allowed_trip_columns():
9393

9494

9595
def get_uuids_columns():
96-
columns = set(constants.valid_uuids_columns)
96+
columns = set(constants.VALID_UUIDS_COLS)
9797
for column in permissions.get("data_uuids_columns_exclude", []):
9898
columns.discard(column)
9999
return columns

0 commit comments

Comments
 (0)