-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add time range parameters to sync script (#483)
This PR adds start and end times to the sync data script. The command line arguments `start_time` and `end_time` are added to the `sync_data` script. The script is called as, e.g., ```bash python -m src.data_sync.sync_data --sync-table order_data --start-time 2025-12-30 --end-time 2025-01-07 ``` Only data between `start_time` and `end_time` is computed. This data is then _upserted_ into the corresponding table of the month. I.e. if a row was not in the table already, it is inserted into the table. Rows from the new data replace rows of the old data if it exists. Old data which was not recomputed stays as is. The code is structured as follows: 1. Arguments are parsed with appropriate default values. 2. The full time range is partitioned into monthly ranges. 3. Block ranges and months are computed from those time ranges. 4. Essentially the old code is used for computing data for those block ranges. 5. Data is written to the database. The convention for the stat time to be inclusive and for the end time to be exclusive is used. This way the two ranges `(2024-12-30, 2025-01-02), (2025-01-02, 2025-01-07)` would give the same result as the range `(2024-12-30, 2025-01-07)`. Though some overlap is required in cases `end_time` is beyond the last finalized block. If no argument is supplied, the start of the month and the start of the next month are used as default for `start_time` and `end_time`, respectively, to compute data for the full month, until the last finalized block. The previous month is not automatically recomputed on the first of the next month. Instead, one can use a time range which contains whatever time window for which data needs to be recomputed. --------- Co-authored-by: Haris Angelidakis <[email protected]>
- Loading branch information
Showing
6 changed files
with
231 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.