diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-12-29 16:17:39 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-12-29 16:20:26 +1100 |
| commit | 20d69469a4c80a196de23625d0420487b0ed04a6 (patch) | |
| tree | e3a7aad153e72322c0810c66bda3b70daa8d815a /backend/hist_data/gen_disp_data.py | |
| parent | 4ad7206443660587a15a7b47384b927188155da8 (diff) | |
Show event-count data on timeline
Backend:
Send event-count data to client in EventResponse instance
Fix certain usages of gregorian calendar instead of julian
Move HistDate, SCALES, etc, into cal.py
Frontend:
Make App update a unitCountMaps object using event-count data from server
Make TimeLine show visual indication of unit counts
Add showEventCounts option to store
Update unit tests
Diffstat (limited to 'backend/hist_data/gen_disp_data.py')
| -rw-r--r-- | backend/hist_data/gen_disp_data.py | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/backend/hist_data/gen_disp_data.py b/backend/hist_data/gen_disp_data.py index e425efc..a81263f 100644 --- a/backend/hist_data/gen_disp_data.py +++ b/backend/hist_data/gen_disp_data.py @@ -10,13 +10,9 @@ parentDir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(parentDir) import sqlite3 -from cal import gregorianToJdn, jdnToGregorian +from cal import SCALES, dbDateToHistDate, dateToUnit -MONTH_SCALE = -1; -DAY_SCALE = -2; -SCALES: list[int] = [int(x) for x in [1e9, 1e8, 1e7, 1e6, 1e5, 1e4, 1e3, 100, 10, 1, MONTH_SCALE, DAY_SCALE]]; MAX_DISPLAYED_PER_UNIT = 4 -# DB_FILE = 'data.db' def genData(dbFile: str, scales: list[int], maxDisplayedPerUnit: int) -> None: @@ -36,18 +32,7 @@ def genData(dbFile: str, scales: list[int], maxDisplayedPerUnit: int) -> None: print(f'At iteration {iterNum}') # For each scale for scale in scales: - # Get unit - unit: int - if scale >= 1: - unit = (eventStart if fmt == 0 else jdnToGregorian(eventStart)[0]) // scale - elif scale == MONTH_SCALE: - if fmt == 0: - unit = gregorianToJdn(eventStart, 1, 1) - else: - year, month, day = jdnToGregorian(eventStart) - unit = eventStart if day == 1 else gregorianToJdn(year, month, 1) - else: # scale == DAY_SCALE - unit = eventStart if fmt != 0 else gregorianToJdn(eventStart, 1, 1) + unit = dateToUnit(dbDateToHistDate(eventStart, fmt), scale) # Update maps counts: list[int] if (scale, unit) in scaleUnitToCounts: |
