移除 OI 残留:UserProfile 的 oi_problems_status / total_score / add_score
判题不再写入 OI 相关状态后,UserProfile 上的 OI 字段永远为空/为 0: - 删除 oi_problems_status、total_score 两列及 add_score() 方法 - ProfileProblemDisplayIDRefreshAPI 去掉 oi_problems 合并分支 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -517,17 +517,14 @@ class ProfileProblemDisplayIDRefreshAPI(AsyncAPIView):
|
||||
async def get(self, request):
|
||||
profile = await UserProfile.objects.aget(user=request.user)
|
||||
acm_problems = profile.acm_problems_status.get("problems", {})
|
||||
oi_problems = profile.oi_problems_status.get("problems", {})
|
||||
ids = list(acm_problems.keys()) + list(oi_problems.keys())
|
||||
ids = list(acm_problems.keys())
|
||||
if not ids:
|
||||
return self.success()
|
||||
display_ids = [did async for did in Problem.objects.filter(id__in=ids, visible=True).values_list("_id", flat=True)]
|
||||
id_map = dict(zip(ids, display_ids))
|
||||
for k, v in acm_problems.items():
|
||||
v["_id"] = id_map[k]
|
||||
for k, v in oi_problems.items():
|
||||
v["_id"] = id_map[k]
|
||||
await profile.asave(update_fields=["acm_problems_status", "oi_problems_status"])
|
||||
await profile.asave(update_fields=["acm_problems_status"])
|
||||
return self.success()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user