Add state to stage
This state is required to stop the group stage and trigger playoff generation, it is (for now) irrelevant for anything other than that.
This commit is contained in:
parent
0e52663d46
commit
155ce57723
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Stage < ApplicationRecord
|
||||
enum state: %i[playoff_stage in_progress finished]
|
||||
|
||||
belongs_to :tournament
|
||||
has_many :matches, dependent: :destroy
|
||||
has_many :groups, dependent: :destroy
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class StageSerializer < ApplicationSerializer
|
||||
attributes :level
|
||||
attributes :level, :state
|
||||
|
||||
has_many :matches
|
||||
has_many :groups
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class GroupStageService
|
|||
raise 'Groups need to be equal size' unless (groups.flatten.length.to_f / groups.length.to_f % 1).zero?
|
||||
|
||||
groups = groups.map(&method(:get_group_object_from))
|
||||
Stage.new level: -1, groups: groups
|
||||
Stage.new level: -1, groups: groups, state: :in_progress
|
||||
end
|
||||
|
||||
def get_group_object_from(team_array)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class CreateSchema < ActiveRecord::Migration[5.2]
|
|||
|
||||
create_table :stages do |t|
|
||||
t.integer :level
|
||||
t.integer :state, default: 0
|
||||
|
||||
t.belongs_to :tournament, index: true, foreign_key: { on_delete: :cascade }, null: false
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ FactoryBot.define do
|
|||
tournament
|
||||
factory :group_stage do
|
||||
level { -1 }
|
||||
state { :in_progress }
|
||||
transient do
|
||||
group_count { 4 }
|
||||
match_factory { :group_match }
|
||||
|
|
|
|||
Loading…
Reference in New Issue