Add indicator for processed messages
All checks were successful
CI / scan_ruby (push) Successful in 17s
CI / scan_js (push) Successful in 12s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 36s

This commit is contained in:
sto
2025-06-18 18:42:04 +02:00
parent 96b8553b1f
commit 67d2ef41b3
13 changed files with 42 additions and 11 deletions

View File

@@ -10,28 +10,32 @@
# updated_at :datetime not null
# contest_id :integer not null
# contestant_id :integer not null
# message_id :integer
# puzzle_id :integer not null
#
# Indexes
#
# index_completions_on_contest_id (contest_id)
# index_completions_on_contestant_id (contestant_id)
# index_completions_on_message_id (message_id)
# index_completions_on_puzzle_id (puzzle_id)
#
# Foreign Keys
#
# contest_id (contest_id => contests.id)
# contestant_id (contestant_id => contestants.id)
# message_id (message_id => messages.id)
# puzzle_id (puzzle_id => puzzles.id)
#
class Completion < ApplicationRecord
belongs_to :contest
belongs_to :contestant
belongs_to :puzzle
belongs_to :message, optional: true
before_save :add_time_seconds
validates :display_time_from_start, presence: true, format: { with: /\A((\d\d|\d):\d\d|\d\d|\d):\d\d\z/ }
validates :display_time_from_start, presence: true, format: { with: /\A(((\d\d|\d):\d\d|\d\d|\d):\d\d|\d\d|\d)\z/ }
validates :puzzle_id, uniqueness: { scope: :contestant }
def add_time_seconds

View File

@@ -27,7 +27,7 @@ class Contest < ApplicationRecord
has_many :completions, dependent: :destroy
has_many :contestants, dependent: :destroy
has_many :puzzles, dependent: :destroy
has_many :messages
has_many :messages, dependent: :destroy
friendly_id :name, use: :slugged

View File

@@ -21,6 +21,7 @@
#
class Message < ApplicationRecord
belongs_to :contest
has_many :completions, dependent: :nullify
validates :author, presence: true
validates :text, presence: true