Skip to content

Commit b0fc2b3

Browse files
committed
🐛 fix: update for leetcode.com API change—replaced username field with user_slug. Temporary workaround: set both fields to the same value.
1 parent 06052f5 commit b0fc2b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/handler/contest_record.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ async def _fill_old_rating_and_count(_contest_record: ContestRecordPredict):
3939
).delete()
4040
unique_keys = set()
4141
for contest_record_dict in contest_record_list:
42+
# TODO: LCUS changed API, now we have to use `user_slug`
43+
contest_record_dict["username"] = contest_record_dict["user_slug"]
4244
key = (contest_record_dict["data_region"], contest_record_dict["username"])
4345
if key in unique_keys:
4446
# during the contest, request_contest_ranking may return duplicated records (user ranking is changing)
@@ -82,6 +84,8 @@ async def save_archive_contest_records(
8284
)
8385
contest_records = list()
8486
for contest_record_dict in contest_record_list:
87+
# TODO: LCUS changed API, now we have to use `user_slug`
88+
contest_record_dict["username"] = contest_record_dict["user_slug"]
8589
contest_record_dict.update({"contest_name": contest_name})
8690
contest_record = ContestRecordArchive.model_validate(contest_record_dict)
8791
contest_records.append(contest_record)

0 commit comments

Comments
 (0)