活跃用户改为两年
This commit is contained in:
@@ -165,14 +165,14 @@ class ProblemSolvedPeopleCount(APIView):
|
|||||||
if submission_count == 0:
|
if submission_count == 0:
|
||||||
return self.success("0%")
|
return self.success("0%")
|
||||||
today = datetime.today()
|
today = datetime.today()
|
||||||
oneYearAge = datetime(today.year - 1, today.month, today.day, 0, 0)
|
twoYearAge = datetime(today.year - 2, today.month, today.day, 0, 0)
|
||||||
total_count = User.objects.filter(
|
total_count = User.objects.filter(
|
||||||
is_disabled=False, last_login__gte=oneYearAge
|
is_disabled=False, last_login__gte=twoYearAge
|
||||||
).count()
|
).count()
|
||||||
accepted_count = Submission.objects.filter(
|
accepted_count = Submission.objects.filter(
|
||||||
problem_id=problem_id,
|
problem_id=problem_id,
|
||||||
result=JudgeStatus.ACCEPTED,
|
result=JudgeStatus.ACCEPTED,
|
||||||
create_time__gte=oneYearAge,
|
create_time__gte=twoYearAge,
|
||||||
).aggregate(user_count=Count("user_id", distinct=True))["user_count"]
|
).aggregate(user_count=Count("user_id", distinct=True))["user_count"]
|
||||||
if accepted_count < total_count:
|
if accepted_count < total_count:
|
||||||
rate = "%.2f" % ((total_count - accepted_count) / total_count * 100)
|
rate = "%.2f" % ((total_count - accepted_count) / total_count * 100)
|
||||||
|
|||||||
Reference in New Issue
Block a user