Abdulwahaab710 / CTFDashB

Capture The Flag (CTF) dashboard 🚩
MIT License
5 stars 5 forks source link

Update team's scores when challenges points has been changed #481

Open Abdulwahaab710 opened 3 years ago

Abdulwahaab710 commented 3 years ago

When a user updates the points for a challenge, we should update the score for all team in a background job. Maybe something like the following:

Team.all.each do |team|
  team.update(score: calculate_team_new_score(team))
end

def calculate_team_new_score(team)
  Submission.where(team: team, valid_submission: true).map { |s| s.challenge.points }.sum
end