Skip to content

Commit 3694925

Browse files
authored
(bug) Fix daily guess submission blocked after timeout (#17)
* fixing startChallenge() field * adding .codex to gitignore
1 parent dc56f8f commit 3694925

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ __pycache__
66
.coverage
77
picturedata.txt
88
node_modules/
9-
dist/
9+
dist/
10+
.codex/

apps/server/src/services/daily.service.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,17 @@ export class DailyService {
151151
const now = new Date();
152152
await prisma.userDaily.upsert({
153153
where: { username },
154-
update: { startedAt: now },
154+
// Reset per-day fields when starting a new day.
155+
// This prevents a previous-day timeout state (played=true + null guess) from blocking submissions
156+
// after we update startedAt for the new day.
157+
update: {
158+
startedAt: now,
159+
played: false,
160+
points: 0,
161+
distance: 0,
162+
guessLat: null,
163+
guessLng: null
164+
},
155165
create: {
156166
username,
157167
startedAt: now
@@ -188,7 +198,12 @@ export class DailyService {
188198
// Check if timed out today (startedAt is today, guessLat is null, AND played is true)
189199
// This handles the case where user timed out but we didn't set lastPlayed
190200
// We must check played === true to distinguish from users who started but haven't submitted yet
191-
if (userDaily.startedAt && userDaily.guessLat === null && userDaily.played === true) {
201+
if (
202+
userDaily.startedAt &&
203+
userDaily.played === true &&
204+
userDaily.guessLat === null &&
205+
userDaily.guessLng === null
206+
) {
192207
const startedAt = new Date(userDaily.startedAt);
193208
startedAt.setHours(0, 0, 0, 0);
194209
if (startedAt.getTime() === today.getTime()) {

0 commit comments

Comments
 (0)