def enhance_problems_for_admin(problems):
for problem in problems:
query = {
'problem_id': problem['_id']
}
snapshot = _db.problem_ranking_snapshots.find_one(
query,
sort=[('snapshot_time', pymongo.DESCENDING)])
if snapshot is None:
problem["solution_count"] = 0
problem["perfect_solution_count"] = 0
else:
problem["solution_count"] = len(snapshot["ranking"])
perfect_solution_count = 0
for solution in snapshot["ranking"]:
if solution["resemblance_int"] == 1000000:
perfect_solution_count += 1
problem["perfect_solution_count"] = perfect_solution_count
评论列表
文章目录