Fix more bad bugs

This commit is contained in:
Matthias Portzel 2024-03-19 23:16:12 -04:00
parent 2b5ae391b2
commit 1c71c41669
3 changed files with 8 additions and 4 deletions

View File

@ -92,7 +92,7 @@ define_command("Solve", [
event.respond content: "Correct! You've gained full access for this week.", ephemeral: true
event.channel.send "<@#{event.user.id}> has given the solution and entered the club."
# Create "solve" instance
Solve.create discord_id: event.user.id, puzzle: current_puzzle.id
Solve.create discord_id: event.user.id, puzzle_id: current_puzzle.id
# TODO: Update "solves" count role
else
event.respond content: "Hmm, that's not the answer we're looking for.", ephemeral: true

View File

@ -13,6 +13,10 @@ class SendPuzzleJob < ActiveJob::Base
# Set the previous puzzle as used
current_puzzle = Puzzle.current.first
if current_puzzle.nil?
$study_channel.send "Aborting send puzzle job because there's no current puzzle"
self.class.enqueue
end
current_puzzle.state = "used"
last_public_id = current_puzzle.public_id
current_puzzle.save
@ -48,6 +52,7 @@ class SendPuzzleJob < ActiveJob::Base
end
def self.enqueue
self.set(wait: 1.minute).perform_later
# Get ready to send the next puzzle at the next UTC sunday
self.set(wait_until: Date.today.next_occurring(:sunday).beginning_of_day).perform_later
end
end

View File

@ -25,7 +25,6 @@ class UpdateStatusJob < ActiveJob::Base
end
def self.enqueue
# Get ready to send the next puzzle at the next UTC sunday
self.set(wait_until: Date.today.next_occurring(:sunday).beginning_of_day).perform_later
self.set(wait: 1.minute).perform_later
end
end