Add waiting room to create programming groups (#1919)

Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
This commit is contained in:
Kira Grammel
2023-09-21 15:07:10 +02:00
committed by GitHub
parent 1dfc306e76
commit 9f837412c7
15 changed files with 174 additions and 48 deletions

View File

@ -0,0 +1,25 @@
# frozen_string_literal: true
class PairProgrammingWaitingUser < ApplicationRecord
include Creation
belongs_to :exercise
belongs_to :programming_group, optional: true
enum status: {
waiting: 0,
joined_pg: 1,
disconnected: 2,
worked_alone: 3,
created_pg: 4,
}, _prefix: true
validates :user_id, uniqueness: {scope: %i[exercise_id user_type]}
validates :programming_group_id, presence: true, if: -> { status_joined_pg? || status_created_pg? }
after_save :capture_event
def capture_event
Event.create(category: 'pp_matching', user:, exercise:, data: status.to_s)
end
end