Skip to content

Commit

Permalink
Slightly change the way we validate 333mbf results
Browse files Browse the repository at this point in the history
  • Loading branch information
viroulep committed Oct 14, 2018
1 parent c4ad699 commit 4f59bfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions WcaOnRails/app/models/upload_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def import_to_inbox
rescue ActiveRecord::RecordInvalid => invalid
object = invalid.record
if object.class == Scramble
errors.add(:results_file, "Scramble in round #{object.roundTypeId} of event #{object.eventId} is invalid (#{invalid.message}), please fix it!")
errors.add(:results_file, "Scramble in '#{Round.name_from_attributes_id(object.eventId, object.roundTypeId)}' is invalid (#{invalid.message}), please fix it!")
elsif object.class == InboxPerson
errors.add(:results_file, "Person #{object.name} is invalid (#{invalid.message}), please fix it!")
elsif object.class == InboxResult
errors.add(:results_file, "Result for person #{object.personId} in round #{object.roundTypeId} of event #{object.eventId} is invalid (#{invalid.message}), please fix it!")
errors.add(:results_file, "Result for person #{object.personId} in '#{Round.name_from_attributes_id(object.eventId, object.roundTypeId)}' is invalid (#{invalid.message}), please fix it!")
else
# FIXME: that's actually not supposed to happen, as the only 3 types of records we create are above
errors.add(:results_file, "An invalid record prevented the results from being created: #{invalid.message}")
Expand Down
13 changes: 12 additions & 1 deletion WcaOnRails/lib/competition_results_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def check_individual_results(results_by_round_id)
# - check time limit
# - check cutoff
# - check position
# - for multiblind, check if we should ouput a warning (if time is over the time limit, as the 'Result' object validation allows for time up to 30s over the timelimit)

results_by_round_id.each do |round_id, results_for_round|
expected_pos = 0
Expand Down Expand Up @@ -460,10 +461,11 @@ def check_individual_results(results_by_round_id)
# Checks for cutoff
check_results_for_cutoff(cutoff_for_round, result, round_id, round_info) if cutoff_for_round

completed_solves = all_solve_times.select(&:complete?)

# Checks for time limits if it can be user-specified
if !["333mbf", "333fm"].include?(result.eventId)
cumulative_wcif_round_ids = time_limit_for_round.cumulative_round_ids
completed_solves = all_solve_times.select(&:complete?)
# Now let's try to find a DNF/DNS result followed by a non-DNF/DNS result
# Do the same for DNS.
has_result_after = { SolveTime::DNF => false, SolveTime::DNS => false }
Expand Down Expand Up @@ -525,6 +527,15 @@ def check_individual_results(results_by_round_id)
end
end
end

if result.eventId == "333mbf"
completed_solves.each do |solve_time|
time_limit_seconds = [3600, solve_time.attempted * 600].min
if solve_time.time_seconds > time_limit_seconds
@warnings[:results] << "[#{round_id}] Result '#{solve_time.clock_format}' for #{person_info.name} is over the time limit. Please make sure it is the consequence of +2 penalties before sending the results, or fix the result to DNF."
end
end
end
end
end

Expand Down
9 changes: 7 additions & 2 deletions WcaOnRails/lib/solve_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,13 @@ def multiblind_time_limit
return unless @event.id == "333mbf" && complete?

time_limit_minutes = [60, @attempted * 10].min
if time_minutes > time_limit_minutes
errors.add(:base, "should be less than or equal to #{time_limit_minutes} minutes")
time_limit_seconds = time_limit_minutes * 60
if time_seconds > time_limit_seconds
# We let up to 30s margin for +2 during the attempt
unless time_seconds < (time_limit_seconds + 30) && time_seconds.even?
# The error message 'hide' the fact that we let a 30s margin above the timelimit, but we're fine with it
errors.add(:base, "should be less than or equal to #{time_limit_minutes} minutes")
end
end
end

Expand Down

0 comments on commit 4f59bfc

Please sign in to comment.