From 20d69469a4c80a196de23625d0420487b0ed04a6 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Thu, 29 Dec 2022 16:17:39 +1100 Subject: 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 --- backend/hist_data/gen_disp_data.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'backend/hist_data/gen_disp_data.py') 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: -- cgit v1.2.3