diff --git a/app/database.py b/app/database.py index 20c6bc7..a662c19 100644 --- a/app/database.py +++ b/app/database.py @@ -1,3 +1,4 @@ +import random import sys from datetime import datetime from typing import List, Literal @@ -129,6 +130,7 @@ def upsert_row(conn, row: Row): , rapid , blitz , bullet + , position ) VALUES ( %s @@ -140,6 +142,7 @@ def upsert_row(conn, row: Row): , %s , %s , %s + , %s ) ON CONFLICT (site, username) @@ -150,7 +153,8 @@ def upsert_row(conn, row: Row): languages = EXCLUDED.languages, rapid = EXCLUDED.rapid, blitz = EXCLUDED.blitz, - bullet = EXCLUDED.bullet; + bullet = EXCLUDED.bullet, + position = EXCLUDED.position; """, [ row["site"].value, @@ -162,6 +166,7 @@ def upsert_row(conn, row: Row): row.get("rapid"), row.get("blitz"), row.get("bullet"), + random.randint(0, 1000000), ], ) conn.commit() diff --git a/sql/init.sql b/sql/init.sql index b3e953e..b7244a5 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -13,6 +13,7 @@ CREATE TABLE coach_scraper.export , rapid INT , blitz INT , bullet INT + , position INT ); CREATE UNIQUE INDEX IF NOT EXISTS