Add sample scenario data and reporting updates
This commit is contained in:
1 parent
aa0028e7e0
commit
133bc6ce3f
15 files changed
+444
-238
No files matched your search
@@ -67,7 +67,20 @@ def status():
|
||||
print("PostgreSQL sample records: " + ", ".join(f"{k}={v:,}" for k, v in counts.items()))
|
||||
|
||||
|
||||
def refresh_reports():
|
||||
"""Regenerate today's bundled sample reports only, after a successful data rebuild."""
|
||||
from health_reports import reports_for_game
|
||||
from realistic_seed import SAMPLE_KEYS
|
||||
with connect() as conn:
|
||||
conn.execute('SET LOCAL statement_timeout=0')
|
||||
gids=[r['id'] for r in conn.execute('SELECT id FROM games WHERE sample_key=ANY(%s)',(list(SAMPLE_KEYS),))]
|
||||
conn.execute('DELETE FROM daily_health_reports WHERE game_id=ANY(%s) AND report_date=current_date',(gids,))
|
||||
for gid in gids:
|
||||
reports=reports_for_game(conn,gid)['reports']
|
||||
print(f"Refreshed {len(reports)} reports for game {gid}.",flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("command", choices=["init", "seed", "status", "reset-sample"], default="init", nargs="?")
|
||||
globals()[{"init": "initialize", "seed": "seed", "status": "status", "reset-sample": "reseed"}[parser.parse_args().command]]()
|
||||
parser.add_argument("command", choices=["init", "seed", "status", "reset-sample", "refresh-reports"], default="init", nargs="?")
|
||||
globals()[{"init": "initialize", "seed": "seed", "status": "status", "reset-sample": "reseed", "refresh-reports":"refresh_reports"}[parser.parse_args().command]]()
|
||||
Reference in new issue
Block a user