From 56369bccd977ac726bef70895883e79da4e1edd8 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Mon, 2 Jan 2023 14:51:53 +1100 Subject: 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 --- backend/hist_data/gen_disp_data.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) mode change 100644 => 100755 backend/hist_data/gen_disp_data.py (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 old mode 100644 new mode 100755 index e771e57..d796d92 --- 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() # -- cgit v1.2.3