From df14a1112e28597483de86619dcbd57dc5b15db7 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Wed, 5 Oct 2022 19:52:12 +1100 Subject: Add data serving scripts Add histplorer.py, implementing the http query interface Add unit test Add server.py as a simple backend dev server Update documentation --- backend/hist_data/README.md | 4 ++-- backend/hist_data/gen_pop_data.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'backend/hist_data') diff --git a/backend/hist_data/README.md b/backend/hist_data/README.md index 3fcb8df..96c31b5 100644 --- a/backend/hist_data/README.md +++ b/backend/hist_data/README.md @@ -11,7 +11,7 @@ This directory holds files used to generate the history database data.db. If `start_upper` is present, it and `start` denote an uncertain range of start times. Similarly for 'end' and 'end_upper'. - `fmt` indicates format info for `start`, `start_upper`, `end`, and `end_upper`. - - If 1, they denote a Julian date (with 0.5 removed to align with midnight). + - If 1, they denote a Julian date number. This allows simple comparison of events with day-level precision, but only goes back to 4713 BCE. - If 2, same as 1, but dates are preferably displayed using the Gregorian calendar, not the Julian calendar. For example, William Shakespeare's birth appears 'preferably Julian', but Samuel Johnson's does not. @@ -28,7 +28,7 @@ This directory holds files used to generate the history database data.db. Format: `id INT PRIMARY KEY, img_id INT`
Assocates events with images - `descs`
- Format: `title TEXT PRIMARY KEY, desc TEXT`
+ Format: `id INT PRIMARY KEY, wiki_id INT, desc TEXT`
Associates an event's enwiki title with a short description. # Generating the Database diff --git a/backend/hist_data/gen_pop_data.py b/backend/hist_data/gen_pop_data.py index 46c9c68..8eaa142 100755 --- a/backend/hist_data/gen_pop_data.py +++ b/backend/hist_data/gen_pop_data.py @@ -35,6 +35,7 @@ def genData(pageviewsDb: str, dbFile: str) -> None: # print(f'Result: {len(titleToViews)} out of {len(titleToId)}') dbCur.execute('CREATE TABLE pop (id INT PRIMARY KEY, pop INT)') + dbCur.execute('CREATE INDEX pop_idx ON pop(pop)') for title, views in titleToViews.items(): dbCur.execute('INSERT INTO pop VALUES (?, ?)', (titleToId[title], views)) # -- cgit v1.2.3