Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗃️ 🔨 Add a simple script to reset a snapshot to a particular timestamp
This is very simple pseudocode. - delete all entries written after a particular timestamp - reset all labels that were entered after the timestamp by finding the corresponding confirmed trip and removing the `user_input` ``` to_be_deleted_manual_entries = # entries whose metadata.write_ts > timestamp for me in to_be_deleted_manual_entries: matching_confirmed_trip = ea...find_matching_confirmed_trip(me) del matching_confirmed_trip['data']['user_input'] edb.get_analysis_timeseries_db.delete_many({"metadata.write_ts" > timestamp ) ``` This is essentially the same code as e-mission#103 (comment) but with the matching code changed from ``` confirmed_trip = edb.get_analysis_timeseries_db().find_one({"user_id": t["user_id"], "metadata.key": "analysis/confirmed_trip", "data.start_ts": t["data"]["start_ts"]}) #gets confirmed trip with matching user id & timestamp ``` to ``` confirmed_trip = esdt.get_confirmed_obj_for_user_input_obj(ts, ecwe.Entry(t)) ``` to support the richer matching algorithm. And lots of improvements to the logging Testing done: ``` After parsing, the reset timestamp is 2023-12-20T03:27:00+00:00 -> 1703042820.0 Planning to delete 40502 records from the timeseries Planning to delete 6477 records from the analysis timeseries 6477 number of manual records after cutoff 143 For input 2023-12-20T15:49:36.486127+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T19:04:06.452000+07:00, found confirmed trip starting at 2023-12-20T14:22:50.209000+07:00 with no user input For input 2023-12-19T06:28:58.685000+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T19:05:11.080000+07:00, found confirmed trip starting at 2023-12-19T06:28:58.685000+07:00 with user input {'purpose_confirm': 'ໄປວຽກ', 'mode_confirm': 'motorcycle'} Resetting input of type purpose_confirm Update results = {'n': 1, 'nModified': 1, 'ok': 1.0, 'updatedExisting': True} For input 2023-12-19T05:33:56.424000+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T19:05:18.335000+07:00, found confirmed trip starting at 2023-12-19T05:33:56.424000+07:00 with user input {'purpose_confirm': 'ໄປວຽກ', 'mode_confirm': 'motorcycle'} Resetting input of type purpose_confirm Update results = {'n': 1, 'nModified': 1, 'ok': 1.0, 'updatedExisting': True} For input 2023-12-18T20:12:15.920000+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T19:05:28.385000+07:00, found confirmed trip starting at 2023-12-18T20:12:15.920000+07:00 with user input {'purpose_confirm': 'ໄປວຽກ', 'mode_confirm': 'motorcycle'} Resetting input of type purpose_confirm Update results = {'n': 1, 'nModified': 1, 'ok': 1.0, 'updatedExisting': True} For input 2023-12-18T20:12:15.920000+07:00 of type manual/mode_confirm, labeled at 2023-12-20T19:06:27.949000+07:00, found confirmed trip starting at 2023-12-18T20:12:15.920000+07:00 with user input {'mode_confirm': 'motorcycle'} Resetting input of type mode_confirm Update results = {'n': 1, 'nModified': 1, 'ok': 1.0, 'updatedExisting': True} ... For input 2023-12-20T19:31:21.577000+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T20:14:33.454000+07:00, found confirmed trip starting at 2023-12-20T19:05:27.266615+07:00 with no user input For input 2023-12-20T20:02:07.148000+07:00 of type manual/mode_confirm, labeled at 2023-12-20T20:15:57.305000+07:00, found confirmed trip starting at 2023-12-20T19:05:27.266615+07:00 with no user input For input 2023-12-20T20:02:07.148000+07:00 of type manual/purpose_confirm, labeled at 2023-12-20T20:16:02.741000+07:00, found confirmed trip starting at 2023-12-20T19:05:27.266615+07:00 with no user input delete all entries after timestamp 1703042820.0 deleting all timeseries entries after 1703042820.0, {'n': 40502, 'ok': 1.0} deleting all analysis timeseries entries after 1703042820.0, {'n': 6477, 'ok': 1.0} ```
- Loading branch information