Implement PopulateMatchBelow Interactor & Organizer
This commit is contained in:
parent
c77f2c0ac9
commit
dd501ab818
|
|
@ -14,7 +14,7 @@ class MatchesController < ApplicationController
|
||||||
def update
|
def update
|
||||||
new_state = match_params['state']
|
new_state = match_params['state']
|
||||||
if new_state == 'finished'
|
if new_state == 'finished'
|
||||||
PlayoffStageService.populate_match_below(@match) unless @match.group_match?
|
PopulateMatchBelowAndSave.call(match:@match) unless @match.group_match?
|
||||||
end
|
end
|
||||||
if @match.update(match_params)
|
if @match.update(match_params)
|
||||||
render json: @match
|
render json: @match
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class PopulateMatchBelow
|
||||||
|
include Interactor
|
||||||
|
|
||||||
|
def call
|
||||||
|
match = context.match
|
||||||
|
begin
|
||||||
|
PlayoffStageService.populate_match_below(match)
|
||||||
|
context.object_to_save = match
|
||||||
|
rescue StandardError
|
||||||
|
context.fail!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class PopulateMatchBelowAndSave
|
||||||
|
include Interactor::Organizer
|
||||||
|
|
||||||
|
organize PopulateMatchBelow, SaveApplicationRecordObject
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue