Skip to content

Commit 13e95da

Browse files
committed
improved migration logging
1 parent efafcbd commit 13e95da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/migrations/20250728_01_Q3jso-fix-code-table.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ def convert_code_to_bytea(conn):
2121
records = cursor.fetchall()
2222

2323
existing_codes = {}
24+
num_duplicates = 0
25+
num_encoded = 0
2426

2527
for record_id, code_text in records:
2628
# broken with the old code
2729
if code_text.startswith("\\x"):
30+
num_encoded += 1
2831
code_text = bytes.fromhex(code_text[2:]).decode("utf-8")
2932
code_bytes = code_text.encode("utf-8")
3033
# with the old broken code and experimentation, it is possible that we got some
@@ -35,6 +38,7 @@ def convert_code_to_bytea(conn):
3538
(existing_codes[code_bytes], record_id),
3639
)
3740
cursor.execute("DELETE FROM leaderboard.code_files WHERE id = %s", (record_id,))
41+
num_duplicates += 1
3842
continue
3943

4044
existing_codes[code_bytes] = record_id
@@ -44,6 +48,9 @@ def convert_code_to_bytea(conn):
4448
"UPDATE leaderboard.code_files SET code = %s WHERE id = %s", (code_bytes, record_id)
4549
)
4650

51+
print(f"Found and removed {num_duplicates} duplicates")
52+
print(f"Reencoded {num_encoded} code submissions")
53+
4754

4855
def convert_bytea_to_text(conn):
4956
"""Convert existing BYTEA code to TEXT and recalculate hashes"""

0 commit comments

Comments
 (0)