Skip to content

Commit

Permalink
Add API for judges list
Browse files Browse the repository at this point in the history
  • Loading branch information
just806me committed Sep 2, 2023
1 parent 31412c8 commit e88201a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/channels/api_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def subscribed
dispatch_self 'app/start'
dispatch_self 'users/load', task_users.order(:judge_secret).pluck(:judge_secret)
dispatch_self 'criteria/load', task_criterions.order(:position)
dispatch_self 'judges/load', Task.find(task_id).judges
dispatch_self 'results/load', CriterionUserResult.includes(:user).where(criterion: task_criterions)
dispatch_self 'comments/load', Comment.includes(:user).where(task_id:)
dispatch_self 'locks/load', RedisLockManager.all
Expand Down Expand Up @@ -39,6 +40,28 @@ def delete_criterion data
dispatch_all 'criteria/delete', data['id']
end

def add_judge data
return unless scoring_open data

task = Task.find task_id
task.judges << data['value']
task.save!
dispatch_all 'judges/load', task.judges
end

def delete_judge data
return unless scoring_open data

task = Task.find task_id
if task.judges[data['index']] == data['value']
task.judges.delete_at data['index']
task.save!
dispatch_all 'judges/load', task.judges
else
dispatch_self 'errors/push', "Delete failed: Judge #{data['index']} has changed"
end
end

def drag_drop data
return unless scoring_open data

Expand Down

0 comments on commit e88201a

Please sign in to comment.