Skip to content

Commit fe5b070

Browse files
feat: sorting the results by ranks where squares not available (#1023)
Co-authored-by: Adam Zahradník <[email protected]>
1 parent db30437 commit fe5b070

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

bullet/bullet_admin/views/results.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def get_context_data(self, **kwargs):
3030
assert self.detection
3131
ctx = super().get_context_data(**kwargs)
3232
competition = get_active_competition(self.request)
33+
ctx["competition"] = competition
3334
ctx["country"], ctx["language"] = self.detection
3435
ctx["venues"] = Venue.objects.for_competition(competition)
3536
ctx["my_venues"] = Venue.objects.for_request(self.request)

bullet/problems/logic/results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def get_results(
2727

2828
return (
2929
ResultRow.objects.filter(id__in=rows)
30-
.order_by("-solved_count", "-solved_problems", "competition_time")
30+
.order_by(
31+
"-solved_count",
32+
"-solved_problems",
33+
"competition_time",
34+
"team__rank_international",
35+
)
3136
.select_related("team", "team__school", "team__venue", "team__venue__category")
3237
.prefetch_related("team__contestants", "team__contestants__grade")
3338
)

bullet/problems/templates/problems/results.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ <h2 class="text-2xl md:text-4xl mt-4 font-semibold">
3333
</a>
3434

3535
{% for c in countries %}
36+
{% if c != "__" %}{# __ is the legacy OPEN category #}
3637
<a href="{% if competition_number %}{% country_url "archive_results_category" category=category.identifier competition_number=competition_number country=c.code|lower %}{% else %}{% country_url "results_category" category=category.identifier country=c.code|lower %}{% endif %}{% query_transform %}"
37-
class="{% if c == country %} bg-primary text-white font-bold {% else %} bg-gray-100 {% endif %} whitespace-nowrap py-1 px-2 rounded-sm flex gap-2 items-center flex-wrap">
38+
class="{% if c == country %} bg-primary text-white font-bold {% else %} bg-gray-100 {% endif %} whitespace-nowrap py-1 px-2 rounded-sm flex gap-2 items-center flex-wrap">
3839
<iconify-icon icon="flag:{{ c.code|lower }}-4x3" width="none" class="h-4 aspect-4/3"></iconify-icon>
3940
{{ c.name }}
4041
</a>
42+
{% else %}
43+
<a href="{% if competition_number %}{% country_url "archive_results_category" category=category.identifier competition_number=competition_number country=c.code|lower %}{% else %}{% country_url "results_category" category=category.identifier country=c.code|lower %}{% endif %}{% query_transform %}"
44+
class="{% if c == country %} bg-primary text-white font-bold {% else %} bg-gray-100 {% endif %} whitespace-nowrap py-1 px-2 rounded-sm flex gap-2 items-center flex-wrap">
45+
Open
46+
</a>
47+
{% endif %}
4148
{% endfor %}
4249
</div>
4350
{% include "problems/results/table.html" %}

0 commit comments

Comments
 (0)