(add): Counts backend logic, placeholders

This commit is contained in:
2026-06-30 17:42:30 -04:00
parent ff9265645c
commit afe261744f
10 changed files with 502 additions and 2 deletions
+7
View File
@@ -33,6 +33,13 @@ def init_db():
SELECT b.*, t.last_name, t.first_name, t.phone_number, t.pref
FROM baskets b LEFT JOIN tickets t ON b.prefix = t.prefix AND b.winning_ticket = t.t_id
ORDER BY b.prefix, b.b_id""")
cur.execute("""CREATE VIEW IF NOT EXISTS report_counts AS
SELECT prefix, COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))) AS unique_buyers, COUNT(*) AS total_buys
FROM tickets
GROUP BY prefix
UNION ALL
SELECT 'Totals', COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))), COUNT(*)
FROM tickets""")
conn.commit()
conn.close()