Skip to content

Commit

Permalink
Merge pull request #46 from rarimo/fix/daily-questions
Browse files Browse the repository at this point in the history
Fix multiple answer question if answer incorrect and deadline big
  • Loading branch information
Zaptoss authored Oct 4, 2024
2 parents 1f93601 + 7f17d6d commit 4829055
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/config/daily_questions.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ func (q *DailyQuestions) SetDeadline(nullifier string, id int, duration time.Dur
return true
}

func (q *DailyQuestions) ZeroDeadline(nullifier string) *Deadline {
q.mu.Lock()
defer q.mu.Unlock()

deadline, ok := q.deadlines[nullifier]
if !ok {
return nil
}
deadline.At = time.Unix(0, 0)
q.deadlines[nullifier] = deadline

return &deadline
}

func (q *DailyQuestions) ClearDeadlines() map[int]int {
q.mu.Lock()
defer q.mu.Unlock()
Expand Down
2 changes: 2 additions & 0 deletions internal/service/handlers/daily_question_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func CheckDailyQuestion(w http.ResponseWriter, r *http.Request) {
return
}

dq.ZeroDeadline(nullifier)

ape.Render(w, newDailyAnswer(question))
}

Expand Down

0 comments on commit 4829055

Please sign in to comment.