Skip to content

Commit 435c146

Browse files
committed
fix: polish queue table
1 parent c60c0e4 commit 435c146

14 files changed

Lines changed: 236 additions & 161 deletions

File tree

config/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ RUN apt-get update && apt-get install -y \
1010
firejail \
1111
&& rm -rf /var/lib/apt/lists/*
1212

13+
ENV UV_LINK_MODE copy
14+
1315
EXPOSE 8000

othello/apps/games/consumers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,25 @@ def match_update(self, event: dict[str, Any]) -> None:
9797
def send_match_update(self, object_id: int) -> None:
9898
if self.connected:
9999
match = Match.objects.get(id=object_id)
100-
score = "-"
100+
score = "? - ? - ?"
101101
if match.status == "completed":
102-
score = f"{match.player1_wins}-{match.ties}-{match.player2_wins}"
102+
score = f"{match.player1_wins} - {match.ties} - {match.player2_wins}"
103103
self.send_json(
104104
{
105105
"type": "match_update",
106106
"match_id": match.id,
107107
"status": match.status,
108108
"status_display": match.get_status_display(),
109-
"player1": match.player1.get_game_name(),
110-
"player2": match.player2.get_game_name(),
109+
"player1": match.player1.user.username,
110+
"player2": match.player2.user.username,
111111
"ranked": "Yes" if match.is_ranked else "No",
112112
"num_games": match.num_games,
113113
"score": score,
114114
"created_at": match.created_at.isoformat(),
115-
"player1_rating_delta": float(match.player1_rating_delta)
115+
"player1_rating_delta": match.player1_rating_delta
116116
if match.player1_rating_delta
117117
else None,
118-
"player2_rating_delta": float(match.player2_rating_delta)
118+
"player2_rating_delta": match.player2_rating_delta
119119
if match.player2_rating_delta
120120
else None,
121121
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.10 on 2026-02-07 14:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('games', '0036_match_player1_rating_delta_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='match',
15+
name='player1_rating_delta',
16+
field=models.IntegerField(blank=True, null=True),
17+
),
18+
migrations.AlterField(
19+
model_name='match',
20+
name='player2_rating_delta',
21+
field=models.IntegerField(blank=True, null=True),
22+
),
23+
]

othello/apps/games/models.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,8 @@ class Match(models.Model):
143143
player1_wins = models.IntegerField(default=0)
144144
player2_wins = models.IntegerField(default=0)
145145
ties = models.IntegerField(default=0)
146-
player1_rating_delta = models.DecimalField(
147-
max_digits=10, decimal_places=2, null=True, blank=True
148-
)
149-
player2_rating_delta = models.DecimalField(
150-
max_digits=10, decimal_places=2, null=True, blank=True
151-
)
146+
player1_rating_delta = models.IntegerField(null=True, blank=True)
147+
player2_rating_delta = models.IntegerField(null=True, blank=True)
152148

153149
@property
154150
def channels_group_name(self) -> str:
@@ -218,8 +214,8 @@ def calculate_results(self) -> None:
218214
ties=ties,
219215
)
220216

221-
self.player1_rating_delta = change1
222-
self.player2_rating_delta = change2
217+
self.player1_rating_delta = int(change1)
218+
self.player2_rating_delta = int(change2)
223219

224220
user1.rating = rating1 + change1
225221
user2.rating = rating2 + change2

othello/apps/games/views.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.db import models
88
from django.http import FileResponse, HttpRequest, HttpResponse, JsonResponse
99
from django.shortcuts import get_object_or_404, redirect, render
10-
from django.utils import timezone
10+
from django.utils import timezone, formats
1111

1212
from .forms import DownloadSubmissionForm, GameForm, MatchForm, SubmissionForm
1313
from .models import Game, Match, Submission
@@ -191,18 +191,21 @@ def queue_json(request: HttpRequest) -> HttpResponse:
191191
"id": match.id,
192192
"player1_name": match.player1.user.username,
193193
"player2_name": match.player2.user.username,
194-
"score": f"{match.player1_wins}-{match.ties}-{match.player2_wins}"
194+
"score": f"{match.player1_wins} - {match.ties} - {match.player2_wins}"
195195
if match.status == "completed"
196196
else "-",
197197
"is_ranked": "Yes" if match.is_ranked else "No",
198198
"status": match.status,
199199
"status_display": match.get_status_display(),
200-
"created_at": match.created_at.isoformat(),
200+
"created_at": formats.date_format(
201+
timezone.localtime(match.created_at),
202+
"DATETIME_FORMAT",
203+
),
201204
"can_view_replay": request.user in [match.player1.user, match.player2.user],
202-
"player1_rating_delta": float(match.player1_rating_delta)
205+
"player1_rating_delta": match.player1_rating_delta
203206
if match.player1_rating_delta
204207
else None,
205-
"player2_rating_delta": float(match.player2_rating_delta)
208+
"player2_rating_delta": match.player2_rating_delta
206209
if match.player2_rating_delta
207210
else None,
208211
}
@@ -218,6 +221,7 @@ def queue_json(request: HttpRequest) -> HttpResponse:
218221
)
219222

220223

224+
@login_required
221225
def queue(request: HttpRequest) -> HttpResponse:
222226
matches = Match.objects.all().order_by("-created_at")
223227
my_matches_only = request.GET.get("my_matches") == "1"

othello/settings/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,6 @@
245245
integrations=[DjangoIntegration(), CeleryIntegration()],
246246
send_default_pii=True,
247247
)
248+
249+
250+
DATETIME_FORMAT = "F d, Y, h:i a"

othello/static/css/base.css

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@charset "UTF-8";
22

3-
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono');
3+
@import url('https://fonts.googleapis.com/css2?family=Inter');
44

55
body {
6-
font-family: 'Roboto Mono', monospace;
6+
font-family: 'Inter', sans-serif;
77
}
88

99
html, body {
@@ -102,19 +102,19 @@ html, body {
102102

103103

104104
pre, code {
105-
font-family: 'Roboto Mono', monospace;
105+
font-family: 'Inter', sans-serif;
106106
font-size: 16px;
107107
color: #805229;
108108
}
109109

110110
h1,h2,h3,h4,h5,h6 {
111-
font-family: 'Roboto Mono', monospace;
111+
font-family: 'Inter', sans-serif;
112112
display: block;
113113
font-weight: bold;
114114
}
115115

116116
input, button{
117-
font-family: 'Roboto Mono', monospace;
117+
font-family: 'Inter', sans-serif;
118118
font-size: 16px;
119119
color: #805229;
120120
border: #a06633 2px solid;
@@ -164,4 +164,53 @@ input, button{
164164
.status-btn:focus {
165165
outline: none !important;
166166
box-shadow: none !important;
167+
}
168+
169+
.score-column {
170+
white-space: nowrap;
171+
}
172+
173+
.result-circle {
174+
display: inline-flex;
175+
align-items: center;
176+
justify-content: center;
177+
border-radius: 50%;
178+
width: 32px;
179+
height: 32px;
180+
margin: 0 4px;
181+
flex-shrink: 0;
182+
}
183+
184+
.result-circle.result-win {
185+
background-color: #bbf7d0;
186+
}
187+
188+
.result-circle.result-loss {
189+
background-color: #fecaca;
190+
}
191+
192+
.result-circle.result-tie {
193+
background-color: #e5e7eb;
194+
}
195+
196+
.score {
197+
display: inline-block;
198+
}
199+
200+
.rating-delta {
201+
font-size: 0.75rem;
202+
}
203+
204+
.rating-delta.delta-win {
205+
color: #16a34a;
206+
font-weight: 600;
207+
}
208+
209+
.rating-delta.delta-loss {
210+
color: #dc2626;
211+
font-weight: 600;
212+
}
213+
214+
.rating-delta.delta-tie {
215+
color: #6b7280;
167216
}

othello/static/css/games/design.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.selectize-input {
2-
font-family: 'Roboto Mono', monospace;
2+
font-family: 'Inter', sans-serif;
33
font-size: 16px;
44
background-color: transparent;
55
color: #805229;

othello/static/css/tournaments/create.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
.selectize-input {
66
margin-left: 10px;
7-
font-family: 'Roboto Mono', monospace;
7+
font-family: 'Inter', sans-serif;
88
font-size: 16px;
99
background-color: transparent;
1010
color: #805229;

othello/static/css/tournaments/management.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
.selectize-input {
66
margin-left: 10px;
7-
font-family: 'Roboto Mono', monospace;
7+
font-family: 'Inter', sans-serif;
88
font-size: 16px;
99
background-color: transparent;
1010
color: #805229;

0 commit comments

Comments
 (0)