From 8022a1f75617b3e666c03bd25c0956122d1ffa59 Mon Sep 17 00:00:00 2001 From: TeachMeTW Date: Tue, 17 Dec 2024 19:35:54 -0800 Subject: [PATCH] Changed to Aug 21 for the time being --- .../migrations/populate_pipeline_range.py | 3 ++- .../analysisTests/intakeTests/TestUserStat.py | 17 ++++++++++------- emission/tests/common.py | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/historical/migrations/populate_pipeline_range.py b/bin/historical/migrations/populate_pipeline_range.py index 70ee6ade3..c500045b6 100644 --- a/bin/historical/migrations/populate_pipeline_range.py +++ b/bin/historical/migrations/populate_pipeline_range.py @@ -13,6 +13,7 @@ import emission.storage.decorations.analysis_timeseries_queries as esda import emission.analysis.plotting.composite_trip_creation as eapc import emission.analysis.userinput.matcher as eaum +import emission.analysis.result.user_stat as eaurs def add_pipeline_range(process_number, uuid_list, skip_if_no_new_data): import logging @@ -25,7 +26,7 @@ def add_pipeline_range(process_number, uuid_list, skip_if_no_new_data): continue try: - epi._get_and_store_range(uuid, "analysis/composite_trip") + eaurs.get_and_store_user_stats(uuid, "analysis/composite_trip") except Exception as e: print("Found error %s while processing pipeline for user %s, check log files for details" % (e, uuid)) diff --git a/emission/tests/analysisTests/intakeTests/TestUserStat.py b/emission/tests/analysisTests/intakeTests/TestUserStat.py index 260342d86..7b2243322 100644 --- a/emission/tests/analysisTests/intakeTests/TestUserStat.py +++ b/emission/tests/analysisTests/intakeTests/TestUserStat.py @@ -21,6 +21,7 @@ import emission.storage.decorations.analysis_timeseries_queries as esda import emission.core.wrapper.user as ecwu import emission.net.api.stats as enac +import emission.pipeline.intake_stage as epi # Test imports import emission.tests.common as etc @@ -32,16 +33,18 @@ def setUp(self): Set up the test environment by loading real example data for both Android and users. """ # Set up the real example data with entries - etc.setupRealExample(self, "emission/tests/data/real_examples/shankari_2015-aug-27") - + self.testUUID = uuid.uuid4() + with open("emission/tests/data/real_examples/shankari_2015-aug-21") as fp: + self.entries = json.load(fp, object_hook = esj.wrapped_object_hook) # Retrieve the user profile + etc.setupRealExampleWithEntries(self) profile = edb.get_profile_db().find_one({"user_id": self.testUUID}) if profile is None: # Initialize the profile if it does not exist edb.get_profile_db().insert_one({"user_id": self.testUUID}) - etc.runIntakePipeline(self.testUUID) - + #etc.runIntakePipeline(self.testUUID) + epi.run_intake_pipeline_for_user(self.testUUID, skip_if_no_new_data = False) logging.debug("UUID = %s" % (self.testUUID)) def tearDown(self): @@ -72,7 +75,7 @@ def testGetAndStoreUserStats(self): self.assertIn("pipeline_range", profile, "User profile should contain 'pipeline_range'.") self.assertIn("last_call_ts", profile, "User profile should contain 'last_call_ts'.") - expected_total_trips = 8 + expected_total_trips = 5 expected_labeled_trips = 0 self.assertEqual(profile["total_trips"], expected_total_trips, @@ -85,8 +88,8 @@ def testGetAndStoreUserStats(self): self.assertIn("start_ts", pipeline_range, "Pipeline range should contain 'start_ts'.") self.assertIn("end_ts", pipeline_range, "Pipeline range should contain 'end_ts'.") - expected_start_ts = 1440688739.672 - expected_end_ts = 1440729142.709 + expected_start_ts = 1440168891.095 + expected_end_ts = 1440209488.817 self.assertEqual(pipeline_range["start_ts"], expected_start_ts, f"Expected start_ts to be {expected_start_ts}, got {pipeline_range['start_ts']}") diff --git a/emission/tests/common.py b/emission/tests/common.py index 23bb9ec7f..2b31e0d20 100644 --- a/emission/tests/common.py +++ b/emission/tests/common.py @@ -107,7 +107,7 @@ def getRealExampleEmail(testObj): def fillExistingUUID(testObj): userObj = ecwu.User.fromEmail(getRealExampleEmail(testObj)) print("Setting testUUID to %s" % userObj.uuid) - testObj.testUUID = userObj.uuir + testObj.testUUID = userObj.uuid def getRegEmailIfPresent(testObj): if hasattr(testObj, "evaluation") and testObj.evaluation: