diff options
| author | Terry Truong <terry06890@gmail.com> | 2023-01-02 14:51:53 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2023-01-02 14:51:53 +1100 |
| commit | 56369bccd977ac726bef70895883e79da4e1edd8 (patch) | |
| tree | 67a894fe1579f2da150f0162ccbdc8a0a19ef9be /backend/hist_data/gen_disp_data.py | |
| parent | 0e5e46cedaaeacf59cfd0f2e30c1ae6923466870 (diff) | |
Adjust wikidata event specifiers
Do minor refactors:
- Swap fmt=1 and fmt=2 in 'events' table
- Make documentation consistently use BC and AD
- import argparse at start of scripts
Diffstat (limited to 'backend/hist_data/gen_disp_data.py')
| -rwxr-xr-x[-rw-r--r--] | backend/hist_data/gen_disp_data.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/backend/hist_data/gen_disp_data.py b/backend/hist_data/gen_disp_data.py index e771e57..d796d92 100644..100755 --- a/backend/hist_data/gen_disp_data.py +++ b/backend/hist_data/gen_disp_data.py @@ -1,15 +1,18 @@ #!/usr/bin/python3 """ -Adds data about event distribution to the database, and removes events not eligible for display. +Adds data about event distribution to the database, +and removes events not eligible for display """ -# Enable unit testing code to, when running this script, resolve imports of modules within this directory +# Code used in unit testing (for resolving imports of modules within this directory) import os, sys parentDir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(parentDir) - +# Standard imports +import argparse import sqlite3 +# Local imports from cal import SCALES, dbDateToHistDate, dateToUnit MAX_DISPLAYED_PER_UNIT = 4 @@ -62,8 +65,8 @@ def genData(dbFile: str, scales: list[int], maxDisplayedPerUnit: int) -> None: del scaleUnitToCounts[(scale, unit)] else: scaleUnitToCounts[(scale, unit)][0] = count - query2 = 'SELECT events.id FROM events LEFT JOIN pop ON events.id = pop.id WHERE pop.id IS NULL' - for (eventId,) in dbCur.execute(query2): # Include events without scores + for (eventId,) in dbCur.execute( # Find events without scores + 'SELECT events.id FROM events LEFT JOIN pop ON events.id = pop.id WHERE pop.id IS NULL'): eventsToDel.append(eventId) print(f'Found {len(eventsToDel)}') # @@ -91,7 +94,6 @@ def genData(dbFile: str, scales: list[int], maxDisplayedPerUnit: int) -> None: dbCon.close() if __name__ == '__main__': - import argparse parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) args = parser.parse_args() # |
