mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修改rank页面时间格式 hh:mm:ss,修改rank页面时间格式 hh:mm:ss,ContestSubmission中时间以秒计
This commit is contained in:
parent
34f886d990
commit
86c70eb8bd
@ -90,7 +90,7 @@ class ContestSubmission(models.Model):
|
||||
total_submission_number = models.IntegerField(default=1)
|
||||
# 这道题是 AC 还是没过
|
||||
ac = models.BooleanField()
|
||||
# ac 用时
|
||||
# ac 用时以秒计
|
||||
ac_time = models.IntegerField(default=0)
|
||||
# 总的时间,用于acm 类型的,也需要保存罚时
|
||||
total_time = models.IntegerField(default=0)
|
||||
|
||||
@ -392,6 +392,19 @@ def _cmp(x, y):
|
||||
return -1
|
||||
|
||||
|
||||
def get_the_time_format(seconds):
|
||||
result = str(seconds % 60)
|
||||
if seconds % 60 < 10:
|
||||
result = "0" + result
|
||||
result = str((seconds % 3600) / 60) + ":" + result
|
||||
if (seconds % 3600) / 60 < 10:
|
||||
result = "0" + result
|
||||
result = str(seconds / 3600) + ":" + result
|
||||
if seconds / 3600 < 10:
|
||||
result = "0" + result
|
||||
return result
|
||||
|
||||
|
||||
@check_user_contest_permission
|
||||
def contest_rank_page(request, contest_id):
|
||||
contest = Contest.objects.get(id=contest_id)
|
||||
@ -410,17 +423,17 @@ def contest_rank_page(request, contest_id):
|
||||
try:
|
||||
status = submissions.get(problem=problem)
|
||||
result[i]["problems"].append({
|
||||
"first_achieved":status.first_achieved,
|
||||
"first_achieved": status.first_achieved,
|
||||
"ac": status.ac,
|
||||
"failed_number": status.total_submission_number,
|
||||
"ac_time": status.ac_time})
|
||||
"ac_time": get_the_time_format(status.ac_time)})
|
||||
if status.ac:
|
||||
result[i]["problems"][-1]["failed_number"] -= 1
|
||||
except ContestSubmission.DoesNotExist:
|
||||
result[i]["problems"].append({})
|
||||
result[i]["total_ac"] = submissions.filter(ac=True).count()
|
||||
result[i]["username"] = User.objects.get(id=result[i]["user_id"]).username
|
||||
result[i]["total_time"] = submissions.filter(ac=True).aggregate(total_time=Sum("total_time"))["total_time"]
|
||||
result[i]["total_time"] = get_the_time_format(submissions.filter(ac=True).aggregate(total_time=Sum("total_time"))["total_time"])
|
||||
result = sorted(result, cmp=_cmp, reverse=True)
|
||||
r.set("contest_rank_" + contest_id, json.dumps(list(result)))
|
||||
else:
|
||||
|
||||
@ -71,7 +71,7 @@ class MessageQueue(object):
|
||||
contest_problem.total_accepted_number += 1
|
||||
else:
|
||||
# 如果这个提交是错误的,就罚时20分钟
|
||||
contest_submission.total_time += 20
|
||||
contest_submission.total_time += 1200
|
||||
contest_submission.total_submission_number += 1
|
||||
contest_submission.save()
|
||||
contest_problem.save()
|
||||
@ -79,13 +79,13 @@ class MessageQueue(object):
|
||||
# 第一次提交
|
||||
is_ac = submission.result == result["accepted"]
|
||||
if is_ac:
|
||||
total_time = int((submission.create_time - contest.start_time).total_seconds() / 60)
|
||||
total_time = int((submission.create_time - contest.start_time).total_seconds())
|
||||
# 增加题目总的ac数计数器
|
||||
contest_problem.total_accepted_number += 1
|
||||
contest_problem.save()
|
||||
else:
|
||||
# 没过罚时20分钟
|
||||
total_time = 20
|
||||
total_time = 1200
|
||||
ContestSubmission.objects.create(user_id=submission.user_id, contest=contest, problem=contest_problem,
|
||||
ac=is_ac, total_time=total_time)
|
||||
|
||||
|
||||
@ -47,12 +47,10 @@
|
||||
<th scope="row">{{ forloop.counter }}</th>
|
||||
<td>{{ item.username }}</td>
|
||||
<td>{{ item.total_ac }} / {{ item.total_submit }}</td>
|
||||
<td>{% if item.total_time %}{{ item.total_time }} min{% else %}--{% endif %}</td>
|
||||
<td>{% if item.total_time %}{{ item.total_time }}{% else %}--{% endif %}</td>
|
||||
{% for problem in item.problems %}
|
||||
<td class="{% if problem %}{% if problem.ac %}{% if problem.first_achieve %}first-achieved{% else %}alert-success{% endif %}{% else %}alert-danger{% endif %}{% endif %}">
|
||||
{% if problem.ac %}
|
||||
{{ problem.ac_time }}min
|
||||
{% endif %}
|
||||
{% if problem.ac %}{{ problem.ac_time }}{% endif %}
|
||||
{% if problem.failed_number %}
|
||||
(-{{ problem.failed_number }})
|
||||
{% endif %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user