Skip to content

Commit

Permalink
Modified total and labeled trips to match op-admin implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
TeachMeTW committed Nov 8, 2024
1 parent a5d15cd commit 96682d7
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions emission/pipeline/intake_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,22 @@ def _get_and_store_range(user_id, trip_key):
end_ts = None if end_ts == -1 else end_ts
logging.debug(f"End timestamp: {end_ts}")

# Initialize counters
total_trips = 0
labeled_trips = 0

# Retrieve trip entries as an iterator
trip_entries = ts.find_entries([trip_key], time_query=None)

# Iterate through trip_entries once to count total_trips and labeled_trips
for trip in trip_entries:
total_trips += 1
if trip.get('data', {}).get('user_input'):
labeled_trips += 1
logging.info(f"Total trips: {total_trips}, Labeled trips: {labeled_trips}")
# Retrieve trip entries
total_trips = ts.find_entries_count(
key_list=["analysis/confirmed_trip"],
)

labeled_trips = ts.find_entries_count(
key_list=["analysis/confirmed_trip"],
extra_query_list=[{'data.user_input': {'$ne': {}}}]
)

logging.info(f"Total trips: {total_trips}, Labeled trips: {labeled_trips}")
logging.info(type(user_id))
# Retrieve last GET and PUT calls from stats/server_api_time
docs_cursor = edb.get_timeseries_db().find({
"metadata.key": "stats/server_api_time",
"user_id" : user_id
})
logging.debug("Fetched API call statistics.")

Expand Down

0 comments on commit 96682d7

Please sign in to comment.