diff --git a/app/webpacker/components/Tickets/TicketWorkbenches/EditPersonTicketWorkbench.jsx b/app/webpacker/components/Tickets/TicketWorkbenches/EditPersonTicketWorkbench.jsx
index 1693a4f584c..75ab358ca53 100644
--- a/app/webpacker/components/Tickets/TicketWorkbenches/EditPersonTicketWorkbench.jsx
+++ b/app/webpacker/components/Tickets/TicketWorkbenches/EditPersonTicketWorkbench.jsx
@@ -19,7 +19,7 @@ function EditPersonValidations({ ticketDetails }) {
if (error) return ;
return validators.dob.map((validator) => (
- {I18n.t(`validators.person.${validator.id}`)}
+ {I18n.t(`validators.${validator.kind}.${validator.id}`, validator.args)}
));
}
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 75a46406e2f..cdfd57d87a1 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2807,7 +2807,70 @@ en:
#context: The button that is clicked to download the file
download: "Download"
validators:
- person:
+ persons:
dob_jan_one: "The date of birth of %{name} is on January 1st, please ensure it's correct."
dob_too_young: "%{name} seems to be less than 3 years old, please ensure it's correct."
dob_too_old: "%{name} seems to be around 100 years old, please ensure it's correct."
+ person_without_results_error: "There are no results for %{person_name} with person id %{person_id}"
+ results_without_person_error: "There are results for an unknown person with person id %{person_id}"
+ whitespace_in_name_error: "Person '%{name}' has leading/trailing whitespaces or double whitespaces."
+ wrong_wca_id_error: "Person %{name} has a WCA ID which does not exist: %{wca_id}."
+ wrong_parenthesis_format_error: "Opening parenthesis in '%{name}' must be preceded by a space."
+ same_person_name_warning: "There is already at least one person with the name '%{name}' in the WCA database (%{wca_ids}). Please ensure that your '%{name}' is a different person. If not, please assign the correct WCA ID to the user account and regenerate the results JSON."
+ non_matching_dob_warning: "The birthdate '%{dob}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_dob}'). If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
+ non_matching_gender_warning: "The gender '%{gender}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_gender}'). If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
+ empty_gender_warning: "The gender for newcomer %{name} is empty. Valid gender values are 'female', 'male' and 'other'. Please leave a comment to the WRT about this."
+ non_matching_name_warning: "The name '%{name}' provided for %{wca_id} does not match the current record in the WCA database ('%{expected_name}'). "
+ non_matching_country_warning: "The country '%{country}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_country}'). If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
+ multiple_newcomers_with_same_name_warning: "There are multiple new competitors with the exact same name: %{name}. Please ensure that all results are correct for these competitors and that all results are correctly seperated by their corresponding id."
+ wrong_parenthesis_type_error: "The parenthesis character used in '%{name}' is an irregular character, please replace it with a regular parenthesis '(' or ')' and with appropriate spacing."
+ uppercase_name_warning: "'%{name}' has successive uppercase letters in their name. Please confirm that this is indeed the correct spelling or fix the name."
+ lowercase_name_warning: "'%{name}' has a lowercase name. Please confirm that this is indeed the correct spelling or fix the name."
+ missing_period_warning: "'%{name}' has a single letter middle name without an abbreviation period. Please confirm that this is indeed the correct spelling or fix the name."
+ letter_after_period_warning: "'%{name}' is missing a space after a period in their name. Please confirm that this is indeed the correct spelling or fix the name."
+ single_letter_first_or_last_name_warning: "'%{name}' has a single letter as first or last name. Please fix the name or confirm that this is indeed the competitor's correct name according to an official document."
+ single_name_warning: "'%{name}' has only one name. Please confirm that this is indeed the competitor's full name according to an official document."
+ competitor_limit_warning: "The number of persons in the competition (%{n_competitors}) is above the competitor limit (%{competitor_limit}). The results of the competitors registered after the competitor limit was reached must be removed."
+ results:
+ position_fixed_info: "[%{round_id}] Automatically fixed the position of %{person_name} from %{pos} to %{expected_pos}."
+ mbf_result_over_time_limit_warning: "[%{round_id}] Result '%{result}' for %{person_name} is over the time limit. Please ensure this is due to time penalties before sending the results, or fix the result to DNF."
+ result_after_dns_warning: "[%{round_id}] %{person_name} has at least one DNS result followed by a valid result. Please ensure it is indeed a DNS and if so, explain what happened to WRT."
+ similar_results_warning: "[%{round_id}] Results for %{person_name} are similar to the results for %{similar_person_name}. Please ensure that these results are correctly recorded for both competitors."
+ met_cutoff_missing_results_error: "[%{round_id}] %{person_name} met the cutoff but is missing results for the second phase of the round. The cutoff was %{cutoff}."
+ didnt_meet_cutoff_has_results_error: "[%{round_id}] %{person_name} has at least one result for the second phase of the round but didn't meet the cutoff. The cutoff was %{cutoff}."
+ wrong_attempts_for_cutoff_error: "[%{round_id}] %{person_name} is missing at least one attempt for the cutoff phase. Please edit the result to include the missing attempt(s) or update the round's information in the competition's Manage Events page."
+ mismatched_result_format_error: "[%{round_id}] Results for %{person_name} are in the wrong format: expected %{expected_format}, but got %{format}."
+ result_over_time_limit_error: "[%{round_id}] At least one result for %{person_name} is over the time limit for the round, which is %{time_limit} per attempt. All solves over the time limit must be changed to DNF."
+ results_over_cumulative_time_limit_error: "[%{round_ids}] The sum of results for %{person_name} is over the cumulative time limit, which was %{time_limit}."
+ no_round_information_warning: "[%{round_id}] There is no information about the cutoff and time limit for this round. These validations have been skipped. Please update the round's information in the competition's Manage Events page."
+ undef_tl_warning: "[%{round_id}] The time limit for this round is undefined, time limit validations have been skipped. This is expected only for competitions before 2013."
+ suspicious_dnf_warning: "[%{round_ids}] The round has a cumulative time limit, and extrapolating based on %{person_name}'s successful solves, they would have had very little time left for at least one of their DNFs. Please ensure that every DNF and DNS is indeed correct. If the competitor did not start an attempt or did not have any remaining time before starting an attempt, it must be entered as DNS."
+ missing_cumulative_round_id_error: "[%{original_round_id}] Unable to find the round %{wcif_id} for the cumulative time limit specified in the WCIF. Please go to the competition's Manage Events page and remove %{wcif_id} from the cumulative time limit for %{original_round_id}. WST knows about this bug (GitHub issue #3254)."
+ wrong_position_in_results_error: "[%{round_id}] %{person_name} is in the wrong position: expected %{expected_pos}, but got %{pos}."
+ rounds:
+ too_many_qualified_warning: "Round %{round_id}: more competitors qualified than what the advancement condition planned (%{actual} instead of %{expected}, the condition was: %{condition}). Please update the round information in the manage events page."
+ unexpected_round_results_error: "The round %{round_id} is present in the results but was not created on the events tab. Please include the round's information in the competition's manage events page."
+ regulation_9m1_error: "Round %{round_id} has 99 or fewer competitors but has more than two subsequent rounds, which is not permitted as per Regulation 9m1."
+ regulation_9m2_error: "Round %{round_id} has 15 or fewer competitors but has more than one subsequent round, which is not permitted as per Regulation 9m2."
+ regulation_9m3_error: "Round %{round_id} has 7 or fewer competitors but has at least one subsequent round, which is not permitted as per Regulation 9m3."
+ regulation_9p1_error: "Round %{round_id}: Fewer than 25%% of competitors were eliminated, which is not permitted as per Regulation 9p1."
+ old_regulation_9p_error: "Round %{round_id}: There must be at least one competitor eliminated, which is required as per Regulation 9p (competitions before April 2010)."
+ round_9p1_error: "Round %{round_id}: according to the advancement condition (%{condition}), fewer than 25%% of competitors would be eliminated, which is not permitted as per Regulation 9p1. Please update the round information in the manage events page."
+ not_enough_qualified_warning: "Round %{round_id}: according to the events data, at most %{expected} could have proceed, but only %{actual} competed in the round. Please leave a comment about that (or fix the events data if you applied a different advancement condition)."
+ competed_not_qualified_error: "Round %{round_id}: %{ids} competed but did not meet the attempt result advancement condition (%{condition}). Please make sure the advancement condition reflects what was used during the competition, and remove the results if needed."
+ round_not_found_error: "Round %{round_id} could not be found. Please make sure that the WCA website Edit Events panel and WCA Live are in sync."
+ missing_round_results_error: "There are no results for round %{round_id} but it is listed in the events tab. If this round was not held, please remove the round in the competition's manage events page."
+ unexpected_combined_round_error: "No cutoff was announced for '%{round_name}', but it has been detected as a cutoff round in the results. Please update the round's information in the competition's manage events page."
+ events:
+ not_333_main_event_warning: "The selected main event for this competition is %{main_event_id}. How was that event treated as the main event of the competition? Please give WRT a brief explanation (e.g. number of rounds, prizes, declared winner of the competition, ...)."
+ no_main_event_warning: "There is no selected main event for this competition. Please let WRT know that this is correct."
+ unexpected_results_error: "Results are present for %{event_id}, however it is not listed as an official event. Please remove the event from the results or contact the WCAT to request the event to be added to the WCA website."
+ missing_results_warning: "There are no results for %{event_id}, but it is listed as an official event. If the event was held, please reupload your JSON with the results included. If the event was not held, leave a comment for the WRT."
+ scrambles:
+ missing_scrambles_for_round_error: "[%{round_id}] Missing scrambles. Use Scrambles Matcher to add the correct scrambles to the round."
+ missing_scrambles_for_competition_error: "Missing scrambles for the competition. Use Scrambles Matcher to add scrambles."
+ unexpected_scrambles_for_round_error: "[%{round_id}] Too many scrambles. Use Scrambles Matcher to uncheck the unused scrambles."
+ missing_scrambles_for_group_error: "[%{round_id}] Group %{group_id}: missing scrambles, detected only %{actual} instead of %{expected}."
+ missing_scrambles_for_multi_error: "[%{round_id}] While you may have multiple groups in 3x3x3 Multi-Blind, at least one of the groups must contain scrambles for all attempts."
+ multiple_fmc_groups_warning: "[%{round_id}] There are multiple groups of FMC used. If one group of FMC was used, please use the Scrambles Matcher to uncheck the unused scrambles. Otherwise, please include a comment to WRT explaining why multiple groups of FMC were used."
+ wrong_number_of_scramble_sets_error: "[%{round_id}] This round has a different number of scramble sets than specified on the Manage Events tab. Please adjust the number of scramble sets in the Manage Events tab to the number of sets that were used."
diff --git a/lib/results_validators/advancement_conditions_validator.rb b/lib/results_validators/advancement_conditions_validator.rb
index 1cad484a3dc..26688755435 100644
--- a/lib/results_validators/advancement_conditions_validator.rb
+++ b/lib/results_validators/advancement_conditions_validator.rb
@@ -5,20 +5,16 @@ class AdvancementConditionsValidator < GenericValidator
# PV: There used to be an error for regulation 9M, but now all results
# must belong to a round, and rails validations make sure the total
# number of rounds is <= 4, and that each round number is unique.
- REGULATION_9M1_ERROR = "Round %{round_id} has 99 or fewer competitors but has more than two subsequent rounds, which is not permitted as per Regulation 9m1."
- REGULATION_9M2_ERROR = "Round %{round_id} has 15 or fewer competitors but has more than one subsequent round, which is not permitted as per Regulation 9m2."
- REGULATION_9M3_ERROR = "Round %{round_id} has 7 or fewer competitors but has at least one subsequent round, which is not permitted as per Regulation 9m3."
- REGULATION_9P1_ERROR = "Round %{round_id}: Fewer than 25%% of competitors were eliminated, which is not permitted as per Regulation 9p1."
- OLD_REGULATION_9P_ERROR = "Round %{round_id}: There must be at least one competitor eliminated, which is required as per Regulation 9p (competitions before April 2010)."
- ROUND_9P1_ERROR = "Round %{round_id}: according to the advancement condition (%{condition}), fewer than 25%% of competitors would be eliminated," \
- "which is not permitted as per Regulation 9p1. Please update the round information in the manage events page."
- TOO_MANY_QUALIFIED_WARNING = "Round %{round_id}: more competitors qualified than what the advancement condition planned (%{actual} instead of %{expected}, " \
- "the condition was: %{condition}). Please update the round information in the manage events page."
- NOT_ENOUGH_QUALIFIED_WARNING = "Round %{round_id}: according to the events data, at most %{expected} could have proceed, but only %{actual} competed in the round. " \
- "Please leave a comment about that (or fix the events data if you applied a different advancement condition)."
- COMPETED_NOT_QUALIFIED_ERROR = "Round %{round_id}: %{ids} competed but did not meet the attempt result advancement condition (%{condition}). " \
- "Please make sure the advancement condition reflects what was used during the competition, and remove the results if needed."
- ROUND_NOT_FOUND_ERROR = "Round %{round_id} could not be found. Please make sure that the WCA website Edit Events panel and WCA Live are in sync."
+ REGULATION_9M1_ERROR = :regulation_9m1_error
+ REGULATION_9M2_ERROR = :regulation_9m2_error
+ REGULATION_9M3_ERROR = :regulation_9m3_error
+ REGULATION_9P1_ERROR = :regulation_9p1_error
+ OLD_REGULATION_9P_ERROR = :old_regulation_9p_error
+ ROUND_9P1_ERROR = :round_9p1_error
+ TOO_MANY_QUALIFIED_WARNING = :too_many_qualified_warning
+ NOT_ENOUGH_QUALIFIED_WARNING = :not_enough_qualified_warning
+ COMPETED_NOT_QUALIFIED_ERROR = :competed_not_qualified_error
+ ROUND_NOT_FOUND_ERROR = :round_not_found_error
# These are the old "(combined) qualification" and "b-final" rounds.
# They are not taken into account in advancement conditions.
@@ -62,20 +58,20 @@ def run_validation(validator_data)
round_id = "#{event_id}-#{round_type_id}"
if number_of_people_in_round <= 7 && remaining_number_of_rounds > 0
# https://www.worldcubeassociation.org/regulations/#9m3: Rounds with 7 or fewer competitors must not have subsequent rounds.
- @errors << ValidationError.new(:rounds, competition.id,
- REGULATION_9M3_ERROR,
+ @errors << ValidationError.new(REGULATION_9M3_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
if number_of_people_in_round <= 15 && remaining_number_of_rounds > 1
# https://www.worldcubeassociation.org/regulations/#9m2: Rounds with 15 or fewer competitors must have at most one subsequent round.
- @errors << ValidationError.new(:rounds, competition.id,
- REGULATION_9M2_ERROR,
+ @errors << ValidationError.new(REGULATION_9M2_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
if number_of_people_in_round <= 99 && remaining_number_of_rounds > 2
# https://www.worldcubeassociation.org/regulations/#9m1: Rounds with 99 or fewer competitors must have at most one subsequent round.
- @errors << ValidationError.new(:rounds, competition.id,
- REGULATION_9M1_ERROR,
+ @errors << ValidationError.new(REGULATION_9M1_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
@@ -104,8 +100,8 @@ def run_validation(validator_data)
current_persons.include?(r.wca_id) && r.send(sort_by_column) > condition.attempt_result
end.map(&:wca_id)
if people_over_condition.any?
- @errors << ValidationError.new(:rounds, competition.id,
- COMPETED_NOT_QUALIFIED_ERROR,
+ @errors << ValidationError.new(COMPETED_NOT_QUALIFIED_ERROR,
+ :rounds, competition.id,
round_id: round_id,
ids: people_over_condition.join(","),
condition: condition.to_s(previous_round))
@@ -116,8 +112,8 @@ def run_validation(validator_data)
if Date.new(2006, 7, 20) <= comp_start_date &&
comp_start_date <= Date.new(2010, 4, 13)
if number_of_people_in_round >= number_of_people_in_previous_round
- @errors << ValidationError.new(:rounds, competition.id,
- OLD_REGULATION_9P_ERROR,
+ @errors << ValidationError.new(OLD_REGULATION_9P_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
else
@@ -125,31 +121,31 @@ def run_validation(validator_data)
# Article 9p1, since April 14, 2010
# https://www.worldcubeassociation.org/regulations/#9p1: At least 25% of competitors must be eliminated between consecutive rounds of the same event.
if number_of_people_in_round > max_advancing
- @errors << ValidationError.new(:rounds, competition.id,
- REGULATION_9P1_ERROR,
+ @errors << ValidationError.new(REGULATION_9P1_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
if condition
theoretical_number_of_people = condition.max_advancing(previous_results)
if number_of_people_in_round > theoretical_number_of_people
- @warnings << ValidationWarning.new(:rounds, competition.id,
- TOO_MANY_QUALIFIED_WARNING,
+ @warnings << ValidationWarning.new(TOO_MANY_QUALIFIED_WARNING,
+ :rounds, competition.id,
round_id: round_id,
actual: number_of_people_in_round,
expected: theoretical_number_of_people,
condition: condition.to_s(previous_round))
end
if theoretical_number_of_people > max_advancing
- @errors << ValidationError.new(:rounds, competition.id,
- ROUND_9P1_ERROR,
+ @errors << ValidationError.new(ROUND_9P1_ERROR,
+ :rounds, competition.id,
round_id: round_id,
condition: condition.to_s(previous_round))
end
# This comes from https://github.com/thewca/worldcubeassociation.org/issues/5587
if theoretical_number_of_people - number_of_people_in_round >= 3 &&
(number_of_people_in_round / theoretical_number_of_people) <= 0.8
- @warnings << ValidationWarning.new(:rounds, competition.id,
- NOT_ENOUGH_QUALIFIED_WARNING,
+ @warnings << ValidationWarning.new(NOT_ENOUGH_QUALIFIED_WARNING,
+ :rounds, competition.id,
round_id: round_id,
expected: theoretical_number_of_people,
actual: number_of_people_in_round)
@@ -157,8 +153,8 @@ def run_validation(validator_data)
end
end
else
- @errors << ValidationError.new(:rounds, competition.id,
- ROUND_NOT_FOUND_ERROR,
+ @errors << ValidationError.new(ROUND_NOT_FOUND_ERROR,
+ :rounds, competition.id,
round_id: "#{event_id}-#{previous_round_type_id}")
end
end
diff --git a/lib/results_validators/competitor_limit_validator.rb b/lib/results_validators/competitor_limit_validator.rb
index 6ec3320ae20..94d623306a7 100644
--- a/lib/results_validators/competitor_limit_validator.rb
+++ b/lib/results_validators/competitor_limit_validator.rb
@@ -2,8 +2,7 @@
module ResultsValidators
class CompetitorLimitValidator < GenericValidator
- COMPETITOR_LIMIT_WARNING = "The number of persons in the competition (%{n_competitors}) is above the competitor limit (%{competitor_limit}). " \
- "The results of the competitors registered after the competitor limit was reached must be removed."
+ COMPETITOR_LIMIT_WARNING = :competitor_limit_warning
def self.description
"For competition with a competitor limit, this validator checks that this limit is respected."
@@ -25,8 +24,8 @@ def run_validation(validator_data)
total_competitors = competition_data.persons.count
if competition.competitor_limit_enabled && total_competitors > competitor_limit
- @warnings << ValidationWarning.new(:persons, competition.id,
- COMPETITOR_LIMIT_WARNING,
+ @warnings << ValidationWarning.new(COMPETITOR_LIMIT_WARNING,
+ :persons, competition.id,
n_competitors: total_competitors,
competitor_limit: competitor_limit)
end
diff --git a/lib/results_validators/events_rounds_validator.rb b/lib/results_validators/events_rounds_validator.rb
index 0a472573574..b0162196056 100644
--- a/lib/results_validators/events_rounds_validator.rb
+++ b/lib/results_validators/events_rounds_validator.rb
@@ -2,16 +2,13 @@
module ResultsValidators
class EventsRoundsValidator < GenericValidator
- NOT_333_MAIN_EVENT_WARNING = "The selected main event for this competition is %{main_event_id}. " \
- "How was that event treated as the main event of the competition? " \
- "Please give WRT a brief explanation (e.g. number of rounds, prizes, declared winner of the competition, ...)."
- NO_MAIN_EVENT_WARNING = "There is no selected main event for this competition. Please let WRT know that this is correct."
- UNEXPECTED_RESULTS_ERROR = "Results are present for %{event_id}, however it is not listed as an official event. " \
- "Please remove the event from the results or contact the WCAT to request the event to be added to the WCA website."
- UNEXPECTED_ROUND_RESULTS_ERROR = "The round %{round_id} is present in the results but was not created on the events tab. Please include the round's information in the competition's manage events page."
- MISSING_RESULTS_WARNING = "There are no results for %{event_id}, but it is listed as an official event. If the event was held, please reupload your JSON with the results included. If the event was not held, leave a comment for the WRT."
- MISSING_ROUND_RESULTS_ERROR = "There are no results for round %{round_id} but it is listed in the events tab. If this round was not held, please remove the round in the competition's manage events page."
- UNEXPECTED_COMBINED_ROUND_ERROR = "No cutoff was announced for '%{round_name}', but it has been detected as a cutoff round in the results. Please update the round's information in the competition's manage events page."
+ NOT_333_MAIN_EVENT_WARNING = :not_333_main_event_warning
+ NO_MAIN_EVENT_WARNING = :no_main_event_warning
+ UNEXPECTED_RESULTS_ERROR = :unexpected_results_error
+ UNEXPECTED_ROUND_RESULTS_ERROR = :unexpected_round_results_error
+ MISSING_RESULTS_WARNING = :missing_results_warning
+ MISSING_ROUND_RESULTS_ERROR = :missing_round_results_error
+ UNEXPECTED_COMBINED_ROUND_ERROR = :unexpected_combined_round_error
def self.description
"This validator checks that all events and rounds match between what has been announced and what is present in the results. It also check for a main event and emit a warning if there is none (and if 3x3 is not in the results)."
@@ -50,13 +47,13 @@ def run_validation(validator_data)
def check_main_event(competition)
if competition.main_event
if competition.main_event_id != "333" && competition.events.size > 1
- @warnings << ValidationWarning.new(:events, competition.id,
- NOT_333_MAIN_EVENT_WARNING,
+ @warnings << ValidationWarning.new(NOT_333_MAIN_EVENT_WARNING,
+ :events, competition.id,
main_event_id: competition.main_event_id)
end
else
- @warnings << ValidationWarning.new(:events, competition.id,
- NO_MAIN_EVENT_WARNING)
+ @warnings << ValidationWarning.new(NO_MAIN_EVENT_WARNING,
+ :events, competition.id)
end
end
@@ -67,14 +64,14 @@ def check_events_match(competition, results)
real = results.map(&:eventId).uniq
(real - expected).each do |event_id|
- @errors << ValidationError.new(:events, competition.id,
- UNEXPECTED_RESULTS_ERROR,
+ @errors << ValidationError.new(UNEXPECTED_RESULTS_ERROR,
+ :events, competition.id,
event_id: event_id)
end
(expected - real).each do |event_id|
- @warnings << ValidationWarning.new(:events, competition.id,
- MISSING_RESULTS_WARNING,
+ @warnings << ValidationWarning.new(MISSING_RESULTS_WARNING,
+ :events, competition.id,
event_id: event_id)
end
end
@@ -97,19 +94,19 @@ def check_rounds_match(competition, results)
unexpected.delete(equivalent_round_id)
round = expected_rounds_by_ids[round_id]
unless round.round_type.combined?
- @errors << ValidationError.new(:rounds, competition.id,
- UNEXPECTED_COMBINED_ROUND_ERROR,
+ @errors << ValidationError.new(UNEXPECTED_COMBINED_ROUND_ERROR,
+ :rounds, competition.id,
round_name: round.name)
end
else
- @errors << ValidationError.new(:rounds, competition.id,
- MISSING_ROUND_RESULTS_ERROR,
+ @errors << ValidationError.new(MISSING_ROUND_RESULTS_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
end
unexpected.each do |round_id|
- @errors << ValidationError.new(:rounds, competition.id,
- UNEXPECTED_ROUND_RESULTS_ERROR,
+ @errors << ValidationError.new(UNEXPECTED_ROUND_RESULTS_ERROR,
+ :rounds, competition.id,
round_id: round_id)
end
end
diff --git a/lib/results_validators/individual_results_validator.rb b/lib/results_validators/individual_results_validator.rb
index 56058b91a42..9c42b9c1be7 100644
--- a/lib/results_validators/individual_results_validator.rb
+++ b/lib/results_validators/individual_results_validator.rb
@@ -2,26 +2,23 @@
module ResultsValidators
class IndividualResultsValidator < GenericValidator
- MBF_RESULT_OVER_TIME_LIMIT_WARNING = "[%{round_id}] Result '%{result}' for %{person_name} is over the time limit. Please ensure this is due to time penalties before sending the results, or fix the result to DNF."
-
- RESULT_AFTER_DNS_WARNING = "[%{round_id}] %{person_name} has at least one DNS result followed by a valid result. Please ensure it is indeed a DNS and if so, explain what happened to WRT."
- SIMILAR_RESULTS_WARNING = "[%{round_id}] Results for %{person_name} are similar to the results for %{similar_person_name}. Please ensure that these results are correctly recorded for both competitors."
-
- MET_CUTOFF_MISSING_RESULTS_ERROR = "[%{round_id}] %{person_name} met the cutoff but is missing results for the second phase of the round. The cutoff was %{cutoff}."
- DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR = "[%{round_id}] %{person_name} has at least one result for the second phase of the round but didn't meet the cutoff. The cutoff was %{cutoff}."
- WRONG_ATTEMPTS_FOR_CUTOFF_ERROR = "[%{round_id}] %{person_name} is missing at least one attempt for the cutoff phase. " \
- "Please edit the result to include the missing attempt(s) or update the round's information in the competition's Manage Events page."
- MISMATCHED_RESULT_FORMAT_ERROR = "[%{round_id}] Results for %{person_name} are in the wrong format: expected %{expected_format}, but got %{format}."
- RESULT_OVER_TIME_LIMIT_ERROR = "[%{round_id}] At least one result for %{person_name} is over the time limit for the round, which is %{time_limit} per attempt. All solves over the time limit must be changed to DNF."
- RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR = "[%{round_ids}] The sum of results for %{person_name} is over the cumulative time limit, which was %{time_limit}."
- NO_ROUND_INFORMATION_WARNING = "[%{round_id}] There is no information about the cutoff and time limit for this round. These validations have been skipped. Please update the round's information in the competition's Manage Events page."
- UNDEF_TL_WARNING = "[%{round_id}] The time limit for this round is undefined, time limit validations have been skipped. This is expected only for competitions before 2013."
- SUSPICIOUS_DNF_WARNING = "[%{round_ids}] The round has a cumulative time limit, and extrapolating based on %{person_name}'s successful solves, they would have had very little time left for at least one of their DNFs. " \
- "Please ensure that every DNF and DNS is indeed correct. If the competitor did not start an attempt or did not have any remaining time before starting an attempt, it must be entered as DNS."
+ MBF_RESULT_OVER_TIME_LIMIT_WARNING = :mbf_result_over_time_limit_warning
+
+ RESULT_AFTER_DNS_WARNING = :result_after_dns_warning
+ SIMILAR_RESULTS_WARNING = :similar_results_warning
+
+ MET_CUTOFF_MISSING_RESULTS_ERROR = :met_cutoff_missing_results_error
+ DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR = :didnt_meet_cutoff_has_results_error
+ WRONG_ATTEMPTS_FOR_CUTOFF_ERROR = :wrong_attempts_for_cutoff_error
+ MISMATCHED_RESULT_FORMAT_ERROR = :mismatched_result_format_error
+ RESULT_OVER_TIME_LIMIT_ERROR = :result_over_time_limit_error
+ RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR = :results_over_cumulative_time_limit_error
+ NO_ROUND_INFORMATION_WARNING = :no_round_information_warning
+ UNDEF_TL_WARNING = :undef_tl_warning
+ SUSPICIOUS_DNF_WARNING = :suspicious_dnf_warning
# Miscelaneous errors
- MISSING_CUMULATIVE_ROUND_ID_ERROR = "[%{original_round_id}] Unable to find the round %{wcif_id} for the cumulative time limit specified in the WCIF. " \
- "Please go to the competition's Manage Events page and remove %{wcif_id} from the cumulative time limit for %{original_round_id}. WST knows about this bug (GitHub issue #3254)."
+ MISSING_CUMULATIVE_ROUND_ID_ERROR = :missing_cumulative_round_id_error
def self.description
"This validator checks that all results respect the format, time limit, and cutoff information if available. It also looks for similar results within the round."
@@ -58,8 +55,8 @@ def run_validation(validator_data)
unless round_info
# This situation may happen with "old" competitions
- @warnings << ValidationWarning.new(:results, competition.id,
- NO_ROUND_INFORMATION_WARNING,
+ @warnings << ValidationWarning.new(NO_ROUND_INFORMATION_WARNING,
+ :results, competition.id,
round_id: round_id)
next
end
@@ -71,8 +68,8 @@ def run_validation(validator_data)
# were possibly not enforced at the discretion of the WCA Delegate.
# In which case we let the TL undefined, and no errors should be
# generated.
- @warnings << ValidationWarning.new(:results, competition.id,
- UNDEF_TL_WARNING,
+ @warnings << ValidationWarning.new(UNDEF_TL_WARNING,
+ :results, competition.id,
round_id: round_id)
end
@@ -107,8 +104,8 @@ def run_validation(validator_data)
# easy case: each completed result (not DNS, DNF, or SKIPPED) must be below the time limit.
results_over_time_limit = completed_solves.reject { |t| t.time_centiseconds < time_limit_for_round.centiseconds }
if results_over_time_limit&.any?
- @errors << ValidationError.new(:results, competition.id,
- RESULT_OVER_TIME_LIMIT_ERROR,
+ @errors << ValidationError.new(RESULT_OVER_TIME_LIMIT_ERROR,
+ :results, competition.id,
round_id: round_id,
person_name: result.personName,
time_limit: time_limit_for_round.to_s(round_info))
@@ -136,8 +133,8 @@ def check_multi_time_limit(context, competition_id, round_id, completed_solves)
completed_solves.each do |solve_time|
time_limit_seconds = [3600, solve_time.attempted * 600].min
if solve_time.time_seconds > time_limit_seconds
- @warnings << ValidationWarning.new(:results, competition_id,
- MBF_RESULT_OVER_TIME_LIMIT_WARNING,
+ @warnings << ValidationWarning.new(MBF_RESULT_OVER_TIME_LIMIT_WARNING,
+ :results, competition_id,
round_id: round_id,
result: solve_time.clock_format,
person_name: result.personName)
@@ -149,8 +146,8 @@ def check_similar_results(context, index, results_for_round)
competition_id, result, round_id, = context
similar = results_similar_to(result, index, results_for_round)
similar.each do |r|
- @warnings << ValidationWarning.new(:results, competition_id,
- SIMILAR_RESULTS_WARNING,
+ @warnings << ValidationWarning.new(SIMILAR_RESULTS_WARNING,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName,
similar_person_name: r.personName)
@@ -163,8 +160,8 @@ def check_result_after_dns(context, all_solve_times)
# Just use '5' here to get all of them
if first_index && all_solve_times[first_index, 5].any?(&:complete?)
competition_id, result, round_id, = context
- @warnings << ValidationWarning.new(:results, competition_id,
- RESULT_AFTER_DNS_WARNING,
+ @warnings << ValidationWarning.new(RESULT_AFTER_DNS_WARNING,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName)
end
@@ -176,8 +173,8 @@ def check_format_matches(context)
# "check consistency of roundTypeIds and formatIds" across a given round
# Check that the result's format matches the round format
unless round_info.format.id == result.formatId
- @errors << ValidationError.new(:results, competition_id,
- MISMATCHED_RESULT_FORMAT_ERROR,
+ @errors << ValidationError.new(MISMATCHED_RESULT_FORMAT_ERROR,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName,
expected_format: round_info.format.name,
@@ -197,8 +194,8 @@ def check_results_for_cutoff(context, cutoff)
if maybe_qualifying_results.any?(&:skipped?)
# There are at least one skipped results among those in the first phase.
- @errors << ValidationError.new(:results, competition_id,
- WRONG_ATTEMPTS_FOR_CUTOFF_ERROR,
+ @errors << ValidationError.new(WRONG_ATTEMPTS_FOR_CUTOFF_ERROR,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName)
end
@@ -208,8 +205,8 @@ def check_results_for_cutoff(context, cutoff)
if qualifying_results.any?
# Meets the cutoff, no result should be SKIPPED
if skipped.any?
- @errors << ValidationError.new(:results, competition_id,
- MET_CUTOFF_MISSING_RESULTS_ERROR,
+ @errors << ValidationError.new(MET_CUTOFF_MISSING_RESULTS_ERROR,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName,
cutoff: cutoff.to_s(round))
@@ -217,8 +214,8 @@ def check_results_for_cutoff(context, cutoff)
else
# Doesn't meet the cutoff, all results should be SKIPPED
if unskipped.any?
- @errors << ValidationError.new(:results, competition_id,
- DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR,
+ @errors << ValidationError.new(DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR,
+ :results, competition_id,
round_id: round_id,
person_name: result.personName,
cutoff: cutoff.to_s(round))
@@ -245,8 +242,8 @@ def check_cumulative_across_rounds(context, rounds_by_ids, results_by_round_id)
end
unless actual_round_id
# FIXME: this needs to be removed when https://github.com/thewca/worldcubeassociation.org/issues/3254 is fixed.
- @errors << ValidationError.new(:results, competition_id,
- MISSING_CUMULATIVE_ROUND_ID_ERROR,
+ @errors << ValidationError.new(MISSING_CUMULATIVE_ROUND_ID_ERROR,
+ :results, competition_id,
wcif_id: wcif_id, original_round_id: round_id)
end
actual_round_id&.at(0)
@@ -265,8 +262,8 @@ def check_cumulative_across_rounds(context, rounds_by_ids, results_by_round_id)
# Check the sum is below the limit
unless sum_of_times_for_rounds < time_limit_for_round.centiseconds
- @errors << ValidationError.new(:results, competition_id,
- RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR,
+ @errors << ValidationError.new(RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR,
+ :results, competition_id,
round_ids: cumulative_round_ids.join(","),
person_name: result.personName,
time_limit: time_limit_for_round.to_s(round_info))
@@ -280,8 +277,8 @@ def check_cumulative_across_rounds(context, rounds_by_ids, results_by_round_id)
avg_per_solve = sum_of_times_for_rounds.to_f / completed_solves_for_rounds.size
# We want to issue a warning if the estimated time for all solves + DNFs goes roughly over the cumulative time limit by at least 20% (estimation tolerance to reduce false positive).
if (number_of_dnf_solves + completed_solves_for_rounds.size) * avg_per_solve >= 1.2 * time_limit_for_round.centiseconds
- @warnings << ValidationWarning.new(:results, competition_id,
- SUSPICIOUS_DNF_WARNING,
+ @warnings << ValidationWarning.new(SUSPICIOUS_DNF_WARNING,
+ :results, competition_id,
round_ids: cumulative_round_ids.join(","),
person_name: result.personName)
end
diff --git a/lib/results_validators/persons_validator.rb b/lib/results_validators/persons_validator.rb
index 62bc404a412..d0fbd44adb9 100644
--- a/lib/results_validators/persons_validator.rb
+++ b/lib/results_validators/persons_validator.rb
@@ -2,32 +2,28 @@
module ResultsValidators
class PersonsValidator < GenericValidator
- PERSON_WITHOUT_RESULTS_ERROR = "There are no results for %{person_name} with person id %{person_id}"
- RESULTS_WITHOUT_PERSON_ERROR = "There are results for an unknown person with person id %{person_id}"
- WHITESPACE_IN_NAME_ERROR = "Person '%{name}' has leading/trailing whitespaces or double whitespaces."
- WRONG_WCA_ID_ERROR = "Person %{name} has a WCA ID which does not exist: %{wca_id}."
- WRONG_PARENTHESIS_FORMAT_ERROR = "Opening parenthesis in '%{name}' must be preceded by a space."
- DOB_JAN_ONE = "dob_jan_one"
- DOB_TOO_YOUNG = "dob_too_young"
- DOB_TOO_OLD = "dob_too_old"
- SAME_PERSON_NAME_WARNING = "There is already at least one person with the name '%{name}' in the WCA database (%{wca_ids}). " \
- "Please ensure that your '%{name}' is a different person. If not, please assign the correct WCA ID to the user account and regenerate the results JSON."
- NON_MATCHING_DOB_WARNING = "The birthdate '%{dob}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_dob}'). If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
- NON_MATCHING_GENDER_WARNING = "The gender '%{gender}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_gender}'). " \
- "If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
- EMPTY_GENDER_WARNING = "The gender for newcomer %{name} is empty. Valid gender values are 'female', 'male' and 'other'. Please leave a comment to the WRT about this."
- NON_MATCHING_NAME_WARNING = "The name '%{name}' provided for %{wca_id} does not match the current record in the WCA database ('%{expected_name}'). "
- NON_MATCHING_COUNTRY_WARNING = "The country '%{country}' provided for %{name} (%{wca_id}) does not match the current record in the WCA database ('%{expected_country}'). " \
- "If this is an error, fix it. Otherwise, leave a comment to the WRT about it."
- MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING = "There are multiple new competitors with the exact same name: %{name}. Please ensure that all results are correct for these competitors " \
- "and that all results are correctly seperated by their corresponding id."
- WRONG_PARENTHESIS_TYPE_ERROR = "The parenthesis character used in '%{name}' is an irregular character, please replace it with a regular parenthesis '(' or ')' and with appropriate spacing."
- UPPERCASE_NAME_WARNING = "'%{name}' has successive uppercase letters in their name. Please confirm that this is indeed the correct spelling or fix the name."
- LOWERCASE_NAME_WARNING = "'%{name}' has a lowercase name. Please confirm that this is indeed the correct spelling or fix the name."
- MISSING_PERIOD_WARNING = "'%{name}' has a single letter middle name without an abbreviation period. Please confirm that this is indeed the correct spelling or fix the name."
- LETTER_AFTER_PERIOD_WARNING = "'%{name}' is missing a space after a period in their name. Please confirm that this is indeed the correct spelling or fix the name."
- SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING = "'%{name}' has a single letter as first or last name. Please fix the name or confirm that this is indeed the competitor's correct name according to an official document."
- SINGLE_NAME_WARNING = "'%{name}' has only one name. Please confirm that this is indeed the competitor's full name according to an official document."
+ PERSON_WITHOUT_RESULTS_ERROR = :person_without_results_error
+ RESULTS_WITHOUT_PERSON_ERROR = :results_without_person_error
+ WHITESPACE_IN_NAME_ERROR = :whitespace_in_name_error
+ WRONG_WCA_ID_ERROR = :wrong_wca_id_error
+ WRONG_PARENTHESIS_FORMAT_ERROR = :wrong_parenthesis_format_error
+ DOB_JAN_ONE = :dob_jan_one
+ DOB_TOO_YOUNG = :dob_too_young
+ DOB_TOO_OLD = :dob_too_old
+ SAME_PERSON_NAME_WARNING = :same_person_name_warning
+ NON_MATCHING_DOB_WARNING = :non_matching_dob_warning
+ NON_MATCHING_GENDER_WARNING = :non_matching_gender_warning
+ EMPTY_GENDER_WARNING = :empty_gender_warning
+ NON_MATCHING_NAME_WARNING = :non_matching_name_warning
+ NON_MATCHING_COUNTRY_WARNING = :non_matching_country_warning
+ MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING = :multiple_newcomers_with_same_name_warning
+ WRONG_PARENTHESIS_TYPE_ERROR = :wrong_parenthesis_type_error
+ UPPERCASE_NAME_WARNING = :uppercase_name_warning
+ LOWERCASE_NAME_WARNING = :lowercase_name_warning
+ MISSING_PERIOD_WARNING = :missing_period_warning
+ LETTER_AFTER_PERIOD_WARNING = :letter_after_period_warning
+ SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING = :single_letter_first_or_last_name_warning
+ SINGLE_NAME_WARNING = :single_name_warning
def self.description
"This validator checks that Persons data make sense with regard to the competition results and the WCA database."
@@ -72,14 +68,14 @@ def run_validation(validator_data)
detected_person_ids = persons_by_id.keys
persons_with_results = results_for_comp.map(&:personId)
(detected_person_ids - persons_with_results).each do |person_id|
- @errors << ValidationError.new(:persons, competition.id,
- PERSON_WITHOUT_RESULTS_ERROR,
+ @errors << ValidationError.new(PERSON_WITHOUT_RESULTS_ERROR,
+ :persons, competition.id,
person_id: person_id,
person_name: persons_by_id[person_id].name)
end
(persons_with_results - detected_person_ids).each do |person_id|
- @errors << ValidationError.new(:persons, competition.id,
- RESULTS_WITHOUT_PERSON_ERROR,
+ @errors << ValidationError.new(RESULTS_WITHOUT_PERSON_ERROR,
+ :persons, competition.id,
person_id: person_id)
end
@@ -87,8 +83,8 @@ def run_validation(validator_data)
if without_wca_id.any?
existing_person_in_db_by_name = Person.where(name: without_wca_id.map(&:name)).group_by(&:name)
existing_person_in_db_by_name.each do |name, persons|
- @warnings << ValidationWarning.new(:persons, competition.id,
- SAME_PERSON_NAME_WARNING,
+ @warnings << ValidationWarning.new(SAME_PERSON_NAME_WARNING,
+ :persons, competition.id,
name: name,
wca_ids: persons.map(&:wca_id).join(", "))
end
@@ -96,8 +92,8 @@ def run_validation(validator_data)
duplicate_newcomer_names = []
without_wca_id.each do |p|
if p.gender.blank?
- @warnings << ValidationWarning.new(:persons, competition.id,
- EMPTY_GENDER_WARNING,
+ @warnings << ValidationWarning.new(EMPTY_GENDER_WARNING,
+ :persons, competition.id,
name: p.name)
end
@@ -110,18 +106,18 @@ def run_validation(validator_data)
end
# Look for double whitespaces or leading/trailing whitespaces.
unless p.name.squeeze(" ").strip == p.name
- @errors << ValidationError.new(:persons, competition.id,
- WHITESPACE_IN_NAME_ERROR,
+ @errors << ValidationError.new(WHITESPACE_IN_NAME_ERROR,
+ :persons, competition.id,
name: p.name)
end
if /[[:alnum:]]\(/ =~ p.name
- @errors << ValidationError.new(:persons, competition.id,
- WRONG_PARENTHESIS_FORMAT_ERROR,
+ @errors << ValidationError.new(WRONG_PARENTHESIS_FORMAT_ERROR,
+ :persons, competition.id,
name: p.name)
end
if /[()]/ =~ p.name
- @errors << ValidationError.new(:persons, competition.id,
- WRONG_PARENTHESIS_TYPE_ERROR,
+ @errors << ValidationError.new(WRONG_PARENTHESIS_TYPE_ERROR,
+ :persons, competition.id,
name: p.name)
end
# Look for if 2 new competitors that share the exact same name
@@ -136,43 +132,43 @@ def run_validation(validator_data)
end
split_name = roman_readable.split
if split_name.first.downcase == split_name.first || split_name.last.downcase == split_name.last
- @warnings << ValidationWarning.new(:persons, competition.id,
- LOWERCASE_NAME_WARNING,
+ @warnings << ValidationWarning.new(LOWERCASE_NAME_WARNING,
+ :persons, competition.id,
name: p.name)
end
if split_name.any? { |n| n =~ /[[:upper:]]{2}/ && n.length > 2 && n != 'III' } # Roman numerals are allowed as suffixes
- @warnings << ValidationWarning.new(:persons, competition.id,
- UPPERCASE_NAME_WARNING,
+ @warnings << ValidationWarning.new(UPPERCASE_NAME_WARNING,
+ :persons, competition.id,
name: p.name)
end
if split_name.length == 1
- @warnings << ValidationWarning.new(:persons, competition.id,
- SINGLE_NAME_WARNING,
+ @warnings << ValidationWarning.new(SINGLE_NAME_WARNING,
+ :persons, competition.id,
name: p.name)
elsif split_name.length > 2
if split_name[1, split_name.length-2].any? { |n| n.length == 1 }
- @warnings << ValidationWarning.new(:persons, competition.id,
- MISSING_PERIOD_WARNING,
+ @warnings << ValidationWarning.new(MISSING_PERIOD_WARNING,
+ :persons, competition.id,
name: p.name)
end
end
if split_name.any? { |n| n.chop.include? '.' }
- @warnings << ValidationWarning.new(:persons, competition.id,
- LETTER_AFTER_PERIOD_WARNING,
+ @warnings << ValidationWarning.new(LETTER_AFTER_PERIOD_WARNING,
+ :persons, competition.id,
name: p.name)
end
non_word_after_first_letter = [' ', '.'].include?(roman_readable[1])
space_before_last_letter = (roman_readable[-2] == " ") && !['I', 'V'].include?(roman_readable[-1]) # Roman numerals are allowed as suffixes
abbreviated_last_name = (roman_readable[-1] == ".") && (roman_readable[-3] == " ")
if non_word_after_first_letter || space_before_last_letter || abbreviated_last_name
- @warnings << ValidationWarning.new(:persons, competition.id,
- SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING,
+ @warnings << ValidationWarning.new(SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING,
+ :persons, competition.id,
name: p.name)
end
end
duplicate_newcomer_names.each do |name|
- @warnings << ValidationWarning.new(:persons, competition.id,
- MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING,
+ @warnings << ValidationWarning.new(MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING,
+ :persons, competition.id,
name: name)
end
with_wca_id.each do |p|
@@ -183,35 +179,35 @@ def run_validation(validator_data)
# WRT wants to show warnings for wrong person information.
# (If I get this right, we do not actually update existing persons from InboxPerson)
unless p.dob == existing_person.dob
- @warnings << ValidationWarning.new(:persons, competition.id,
- NON_MATCHING_DOB_WARNING,
+ @warnings << ValidationWarning.new(NON_MATCHING_DOB_WARNING,
+ :persons, competition.id,
name: p.name, wca_id: p.wca_id,
expected_dob: existing_person.dob,
dob: p.dob)
end
unless p.gender == existing_person.gender
- @warnings << ValidationWarning.new(:persons, competition.id,
- NON_MATCHING_GENDER_WARNING,
+ @warnings << ValidationWarning.new(NON_MATCHING_GENDER_WARNING,
+ :persons, competition.id,
name: p.name, wca_id: p.wca_id,
expected_gender: existing_person.gender,
gender: p.gender)
end
unless p.name == existing_person.name
- @warnings << ValidationWarning.new(:persons, competition.id,
- NON_MATCHING_NAME_WARNING,
+ @warnings << ValidationWarning.new(NON_MATCHING_NAME_WARNING,
+ :persons, competition.id,
name: p.name, wca_id: p.wca_id,
expected_name: existing_person.name)
end
unless p.country.id == existing_person.country.id
- @warnings << ValidationWarning.new(:persons, competition.id,
- NON_MATCHING_COUNTRY_WARNING,
+ @warnings << ValidationWarning.new(NON_MATCHING_COUNTRY_WARNING,
+ :persons, competition.id,
name: p.name, wca_id: p.wca_id,
expected_country: existing_person.country_iso2,
country: p.countryId)
end
else
- @errors << ValidationError.new(:persons, competition.id,
- WRONG_WCA_ID_ERROR,
+ @errors << ValidationError.new(WRONG_WCA_ID_ERROR,
+ :persons, competition.id,
name: p.name, wca_id: p.wca_id)
end
end
diff --git a/lib/results_validators/positions_validator.rb b/lib/results_validators/positions_validator.rb
index c561ecf1ecd..22851f2ee4f 100644
--- a/lib/results_validators/positions_validator.rb
+++ b/lib/results_validators/positions_validator.rb
@@ -2,8 +2,8 @@
module ResultsValidators
class PositionsValidator < GenericValidator
- WRONG_POSITION_IN_RESULTS_ERROR = "[%{round_id}] %{person_name} is in the wrong position: expected %{expected_pos}, but got %{pos}."
- POSITION_FIXED_INFO = "[%{round_id}] Automatically fixed the position of %{person_name} from %{pos} to %{expected_pos}."
+ WRONG_POSITION_IN_RESULTS_ERROR = :wrong_position_in_results_error
+ POSITION_FIXED_INFO = :position_fixed_info
def self.description
"This validator checks that positions stored in results are correct with regard to the actual results."
@@ -50,16 +50,16 @@ def run_validation(validator_data)
if expected_pos != result.pos
if @apply_fixes
- @infos << ValidationInfo.new(:results, competition.id,
- POSITION_FIXED_INFO,
+ @infos << ValidationInfo.new(POSITION_FIXED_INFO,
+ :results, competition.id,
round_id: round_id,
person_name: result.personName,
expected_pos: expected_pos,
pos: result.pos)
result.update!(pos: expected_pos)
else
- @errors << ValidationError.new(:results, competition.id,
- WRONG_POSITION_IN_RESULTS_ERROR,
+ @errors << ValidationError.new(WRONG_POSITION_IN_RESULTS_ERROR,
+ :results, competition.id,
round_id: round_id,
person_name: result.personName,
expected_pos: expected_pos,
diff --git a/lib/results_validators/scrambles_validator.rb b/lib/results_validators/scrambles_validator.rb
index 404f2621755..39beef1d872 100644
--- a/lib/results_validators/scrambles_validator.rb
+++ b/lib/results_validators/scrambles_validator.rb
@@ -2,15 +2,13 @@
module ResultsValidators
class ScramblesValidator < GenericValidator
- MISSING_SCRAMBLES_FOR_ROUND_ERROR = "[%{round_id}] Missing scrambles. Use Scrambles Matcher to add the correct scrambles to the round."
- MISSING_SCRAMBLES_FOR_COMPETITION_ERROR = "Missing scrambles for the competition. Use Scrambles Matcher to add scrambles."
- UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR = "[%{round_id}] Too many scrambles. Use Scrambles Matcher to uncheck the unused scrambles."
- MISSING_SCRAMBLES_FOR_GROUP_ERROR = "[%{round_id}] Group %{group_id}: missing scrambles, detected only %{actual} instead of %{expected}."
- MISSING_SCRAMBLES_FOR_MULTI_ERROR = "[%{round_id}] While you may have multiple groups in 3x3x3 Multi-Blind, at least one of the groups must contain scrambles for all attempts."
- MULTIPLE_FMC_GROUPS_WARNING = "[%{round_id}] There are multiple groups of FMC used. If one group of FMC was used, please use the Scrambles Matcher to uncheck the unused " \
- "scrambles. Otherwise, please include a comment to WRT explaining why multiple groups of FMC were used."
- WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR = "[%{round_id}] This round has a different number of scramble sets than specified on the Manage Events tab. " \
- "Please adjust the number of scramble sets in the Manage Events tab to the number of sets that were used."
+ MISSING_SCRAMBLES_FOR_ROUND_ERROR = :missing_scrambles_for_round_error
+ MISSING_SCRAMBLES_FOR_COMPETITION_ERROR = :missing_scrambles_for_competition_error
+ UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR = :unexpected_scrambles_for_round_error
+ MISSING_SCRAMBLES_FOR_GROUP_ERROR = :missing_scrambles_for_group_error
+ MISSING_SCRAMBLES_FOR_MULTI_ERROR = :missing_scrambles_for_multi_error
+ MULTIPLE_FMC_GROUPS_WARNING = :multiple_fmc_groups_warning
+ WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR = :wrong_number_of_scramble_sets_error
def self.description
"This validator checks that all results have matching scrambles, and if possible, checks that the scrambles have the correct number of attempts compared to the expected round format."
@@ -41,8 +39,8 @@ def run_validation(validator_data)
rounds_ids = results_for_comp.map { |r| "#{r.eventId}-#{r.roundTypeId}" }.uniq
if results_for_comp.any? && !scrambles.any?
- @errors << ValidationError.new(:scrambles, competition.id,
- MISSING_SCRAMBLES_FOR_COMPETITION_ERROR,
+ @errors << ValidationError.new(MISSING_SCRAMBLES_FOR_COMPETITION_ERROR,
+ :scrambles, competition.id,
competition_id: competition.id)
next
end
@@ -51,14 +49,14 @@ def run_validation(validator_data)
scrambles_by_round_id = scrambles.group_by { |s| "#{s.eventId}-#{s.roundTypeId}" }
detected_scrambles_rounds_ids = scrambles_by_round_id.keys
(rounds_ids - detected_scrambles_rounds_ids).each do |round_id|
- @errors << ValidationError.new(:scrambles, competition.id,
- MISSING_SCRAMBLES_FOR_ROUND_ERROR,
+ @errors << ValidationError.new(MISSING_SCRAMBLES_FOR_ROUND_ERROR,
+ :scrambles, competition.id,
round_id: round_id)
end
(detected_scrambles_rounds_ids - rounds_ids).each do |round_id|
- @errors << ValidationError.new(:scrambles, competition.id,
- UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR,
+ @errors << ValidationError.new(UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR,
+ :scrambles, competition.id,
round_id: round_id)
end
@@ -75,8 +73,8 @@ def run_validation(validator_data)
# filter out extra scrambles
actual_number_of_scrambles = scrambles_for_group.reject(&:isExtra).size
if actual_number_of_scrambles < expected_number_of_scrambles
- errors_for_round << ValidationError.new(:scrambles, competition.id,
- MISSING_SCRAMBLES_FOR_GROUP_ERROR,
+ errors_for_round << ValidationError.new(MISSING_SCRAMBLES_FOR_GROUP_ERROR,
+ :scrambles, competition.id,
round_id: round_id, group_id: group_id,
actual: actual_number_of_scrambles,
expected: expected_number_of_scrambles)
@@ -84,19 +82,19 @@ def run_validation(validator_data)
end
# Check if the number of groups match the number of scramble sets specified.
if scrambles_by_group_id.size != rounds_info_by_ids[round_id].scramble_set_count
- errors_for_round << ValidationError.new(:scrambles, competition.id,
- WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR,
+ errors_for_round << ValidationError.new(WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR,
+ :scrambles, competition.id,
round_id: round_id)
end
if round_id.start_with?("333fm") && scrambles_by_group_id.size > 1
- @warnings << ValidationWarning.new(:scrambles, competition.id,
- MULTIPLE_FMC_GROUPS_WARNING,
+ @warnings << ValidationWarning.new(MULTIPLE_FMC_GROUPS_WARNING,
+ :scrambles, competition.id,
round_id: round_id)
end
if round_id.start_with?("333mbf")
unless errors_for_round.size < scrambles_by_group_id.keys.size
- @errors << ValidationError.new(:scrambles, competition.id,
- MISSING_SCRAMBLES_FOR_MULTI_ERROR,
+ @errors << ValidationError.new(MISSING_SCRAMBLES_FOR_MULTI_ERROR,
+ :scrambles, competition.id,
round_id: round_id)
end
else
diff --git a/lib/results_validators/validation_issue.rb b/lib/results_validators/validation_issue.rb
index d66466e2bae..01539dd4a48 100644
--- a/lib/results_validators/validation_issue.rb
+++ b/lib/results_validators/validation_issue.rb
@@ -11,7 +11,7 @@ def initialize(id, kind, competition_id, **message_args)
end
def to_s
- I18n.t("validators.person.#{@id}", @args)
+ I18n.t("validators.#{@kind}.#{@id}", **@args, locale: 'en')
end
def ==(other)
diff --git a/spec/lib/results_validators/advancement_conditions_validator_spec.rb b/spec/lib/results_validators/advancement_conditions_validator_spec.rb
index f7594bccf19..2e1d45a924b 100644
--- a/spec/lib/results_validators/advancement_conditions_validator_spec.rb
+++ b/spec/lib/results_validators/advancement_conditions_validator_spec.rb
@@ -102,23 +102,23 @@
if i == 20
# Create a single attempt result over the attempt result condition.
FactoryBot.create(:result, competition: competition2, eventId: "222", roundTypeId: "f", person: fake_person, best: 1800, average: 1800)
- expected_errors << RV::ValidationError.new(:rounds, competition2.id,
- ACV::COMPETED_NOT_QUALIFIED_ERROR,
+ expected_errors << RV::ValidationError.new(ACV::COMPETED_NOT_QUALIFIED_ERROR,
+ :rounds, competition2.id,
round_id: "222-f",
ids: fake_person.wca_id,
condition: first_round.advancement_condition.to_s(first_round))
end
end
- expected_errors << RV::ValidationError.new(:rounds, competition2.id,
- ACV::ROUND_9P1_ERROR,
+ expected_errors << RV::ValidationError.new(ACV::ROUND_9P1_ERROR,
+ :rounds, competition2.id,
round_id: "222-f",
condition: first_round.advancement_condition.to_s(first_round))
expected_warnings = [
- RV::ValidationWarning.new(:rounds, competition2.id,
- ACV::NOT_ENOUGH_QUALIFIED_WARNING,
+ RV::ValidationWarning.new(ACV::NOT_ENOUGH_QUALIFIED_WARNING,
+ :rounds, competition2.id,
round_id: "222-f", expected: 16, actual: 10),
- RV::ValidationWarning.new(:rounds, competition3.id,
- ACV::TOO_MANY_QUALIFIED_WARNING,
+ RV::ValidationWarning.new(ACV::TOO_MANY_QUALIFIED_WARNING,
+ :rounds, competition3.id,
round_id: "333-f", actual: 9, expected: 4,
condition: first_round2.advancement_condition.to_s(first_round2)),
]
@@ -172,20 +172,20 @@
model.import(results, validate: false)
end
expected_errors = [
- RV::ValidationError.new(:rounds, competition1.id,
- ACV::REGULATION_9M1_ERROR,
+ RV::ValidationError.new(ACV::REGULATION_9M1_ERROR,
+ :rounds, competition1.id,
round_id: "333oh-1"),
- RV::ValidationError.new(:rounds, competition1.id,
- ACV::REGULATION_9M2_ERROR,
+ RV::ValidationError.new(ACV::REGULATION_9M2_ERROR,
+ :rounds, competition1.id,
round_id: "333oh-2"),
- RV::ValidationError.new(:rounds, competition1.id,
- ACV::REGULATION_9M3_ERROR,
+ RV::ValidationError.new(ACV::REGULATION_9M3_ERROR,
+ :rounds, competition1.id,
round_id: "333oh-3"),
- RV::ValidationError.new(:rounds, competition1.id,
- ACV::OLD_REGULATION_9P_ERROR,
+ RV::ValidationError.new(ACV::OLD_REGULATION_9P_ERROR,
+ :rounds, competition1.id,
round_id: "333oh-f"),
- RV::ValidationError.new(:rounds, competition2.id,
- ACV::REGULATION_9P1_ERROR,
+ RV::ValidationError.new(ACV::REGULATION_9P1_ERROR,
+ :rounds, competition2.id,
round_id: "222-f"),
]
@@ -207,8 +207,8 @@
Result.import([existent_result, nonexistent_result], validate: false)
acv = ACV.new.validate(competition_ids: [competition1], model: Result)
- expect(acv.errors).to include(RV::ValidationError.new(:rounds, competition1.id,
- ACV::ROUND_NOT_FOUND_ERROR,
+ expect(acv.errors).to include(RV::ValidationError.new(ACV::ROUND_NOT_FOUND_ERROR,
+ :rounds, competition1.id,
round_id: "333bf-1"))
end
end
diff --git a/spec/lib/results_validators/competitor_limit_validator_spec.rb b/spec/lib/results_validators/competitor_limit_validator_spec.rb
index b5d91c6aba2..94fe5a37ea8 100644
--- a/spec/lib/results_validators/competitor_limit_validator_spec.rb
+++ b/spec/lib/results_validators/competitor_limit_validator_spec.rb
@@ -45,8 +45,8 @@
FactoryBot.create(:result, competition: competition2, eventId: "222")
FactoryBot.create(:inbox_result, competition: competition2, eventId: "222")
expected_warnings = [
- RV::ValidationWarning.new(:persons, competition2.id,
- CLV::COMPETITOR_LIMIT_WARNING,
+ RV::ValidationWarning.new(CLV::COMPETITOR_LIMIT_WARNING,
+ :persons, competition2.id,
n_competitors: 11,
competitor_limit: 10),
]
diff --git a/spec/lib/results_validators/events_rounds_validator_spec.rb b/spec/lib/results_validators/events_rounds_validator_spec.rb
index 15598be8c60..c02729f3d4a 100644
--- a/spec/lib/results_validators/events_rounds_validator_spec.rb
+++ b/spec/lib/results_validators/events_rounds_validator_spec.rb
@@ -37,25 +37,25 @@
end
expected_warnings = [
- RV::ValidationWarning.new(:events, competition1.id,
- ERV::NO_MAIN_EVENT_WARNING),
- RV::ValidationWarning.new(:events, competition2.id,
- ERV::NOT_333_MAIN_EVENT_WARNING,
+ RV::ValidationWarning.new(ERV::NO_MAIN_EVENT_WARNING,
+ :events, competition1.id),
+ RV::ValidationWarning.new(ERV::NOT_333_MAIN_EVENT_WARNING,
+ :events, competition2.id,
main_event_id: "222"),
- RV::ValidationWarning.new(:events, competition2.id,
- ERV::MISSING_RESULTS_WARNING,
+ RV::ValidationWarning.new(ERV::MISSING_RESULTS_WARNING,
+ :events, competition2.id,
event_id: "555"),
- RV::ValidationWarning.new(:events, competition1.id,
- ERV::MISSING_RESULTS_WARNING,
+ RV::ValidationWarning.new(ERV::MISSING_RESULTS_WARNING,
+ :events, competition1.id,
event_id: "333"),
]
expected_errors = [
- RV::ValidationError.new(:events, competition2.id,
- ERV::UNEXPECTED_RESULTS_ERROR,
+ RV::ValidationError.new(ERV::UNEXPECTED_RESULTS_ERROR,
+ :events, competition2.id,
event_id: "444"),
- RV::ValidationError.new(:rounds, competition2.id,
- ERV::UNEXPECTED_ROUND_RESULTS_ERROR,
+ RV::ValidationError.new(ERV::UNEXPECTED_ROUND_RESULTS_ERROR,
+ :rounds, competition2.id,
round_id: '444-f'),
]
@@ -101,22 +101,22 @@
skip_round_creation: true)
end
expected_errors = [
- RV::ValidationError.new(:rounds, competition1.id,
- ERV::UNEXPECTED_COMBINED_ROUND_ERROR,
+ RV::ValidationError.new(ERV::UNEXPECTED_COMBINED_ROUND_ERROR,
+ :rounds, competition1.id,
round_name: "3x3x3 One-Handed Final"),
- RV::ValidationError.new(:rounds, competition1.id,
- ERV::MISSING_ROUND_RESULTS_ERROR,
+ RV::ValidationError.new(ERV::MISSING_ROUND_RESULTS_ERROR,
+ :rounds, competition1.id,
round_id: "333oh-1"),
- RV::ValidationError.new(:rounds, competition2.id,
- ERV::UNEXPECTED_ROUND_RESULTS_ERROR,
+ RV::ValidationError.new(ERV::UNEXPECTED_ROUND_RESULTS_ERROR,
+ :rounds, competition2.id,
round_id: "222-c"),
]
expected_warnings = [
- RV::ValidationWarning.new(:events, competition1.id,
- ERV::NO_MAIN_EVENT_WARNING),
- RV::ValidationWarning.new(:events, competition2.id,
- ERV::NOT_333_MAIN_EVENT_WARNING,
+ RV::ValidationWarning.new(ERV::NO_MAIN_EVENT_WARNING,
+ :events, competition1.id),
+ RV::ValidationWarning.new(ERV::NOT_333_MAIN_EVENT_WARNING,
+ :events, competition2.id,
main_event_id: "222"),
]
validator_args.each do |arg|
diff --git a/spec/lib/results_validators/individual_results_validator_spec.rb b/spec/lib/results_validators/individual_results_validator_spec.rb
index db93960cc55..b7ccb548aec 100644
--- a/spec/lib/results_validators/individual_results_validator_spec.rb
+++ b/spec/lib/results_validators/individual_results_validator_spec.rb
@@ -62,8 +62,8 @@
cutoff: cutoff, eventId: "444")
res_over_missing_value.update!(value2: 0)
- errs << RV::ValidationError.new(:results, competition1.id,
- IRV::WRONG_ATTEMPTS_FOR_CUTOFF_ERROR,
+ errs << RV::ValidationError.new(IRV::WRONG_ATTEMPTS_FOR_CUTOFF_ERROR,
+ :results, competition1.id,
round_id: "444-c",
person_name: res_over_missing_value.personName)
@@ -76,8 +76,8 @@
value5: res_over_with_results.value2,
average: res_over_with_results.value2)
- errs << RV::ValidationError.new(:results, competition1.id,
- IRV::DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR,
+ errs << RV::ValidationError.new(IRV::DIDNT_MEET_CUTOFF_HAS_RESULTS_ERROR,
+ :results, competition1.id,
round_id: "444-c",
person_name: res_over_with_results.personName,
cutoff: cutoff.to_s(round44))
@@ -89,8 +89,8 @@
roundTypeId: "c")
res_over_limit.update(value5: 12_001)
- errs << RV::ValidationError.new(:results, competition1.id,
- IRV::RESULT_OVER_TIME_LIMIT_ERROR,
+ errs << RV::ValidationError.new(IRV::RESULT_OVER_TIME_LIMIT_ERROR,
+ :results, competition1.id,
round_id: "444-c",
person_name: res_over_limit.personName,
time_limit: time_limit.to_s(round44))
@@ -101,8 +101,8 @@
formatId: "m", eventId: "333fm")
res_fm.update(value1: 30)
- errs << RV::ValidationError.new(:results, competition2.id,
- IRV::MET_CUTOFF_MISSING_RESULTS_ERROR,
+ errs << RV::ValidationError.new(IRV::MET_CUTOFF_MISSING_RESULTS_ERROR,
+ :results, competition2.id,
round_id: "333fm-c",
person_name: res_fm.personName,
cutoff: cutoff_fm.to_s(round_fm))
@@ -110,16 +110,16 @@
res_cumul = FactoryBot.create(result_kind, :mo3, competition: competition2, eventId: "666", best: 6000)
FactoryBot.create(result_kind, competition: competition2, eventId: "555", best: 6000, average: 6000, person: person_for_result(res_cumul))
- errs << RV::ValidationError.new(:results, competition2.id,
- IRV::RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR,
+ errs << RV::ValidationError.new(IRV::RESULTS_OVER_CUMULATIVE_TIME_LIMIT_ERROR,
+ :results, competition2.id,
round_ids: "555-f,666-f",
person_name: res_cumul.personName,
time_limit: cumul_valid.to_s(round55))
FactoryBot.create(result_kind, :mo3, competition: competition2, eventId: "777")
- errs << RV::ValidationError.new(:results, competition2.id,
- IRV::MISSING_CUMULATIVE_ROUND_ID_ERROR,
+ errs << RV::ValidationError.new(IRV::MISSING_CUMULATIVE_ROUND_ID_ERROR,
+ :results, competition2.id,
original_round_id: "777-f",
wcif_id: "444-r1")
@@ -142,8 +142,8 @@
irv = IRV.new.validate(competition_ids: competition1.id)
expected_warnings = [
- RV::ValidationWarning.new(:results, competition1.id,
- IRV::NO_ROUND_INFORMATION_WARNING,
+ RV::ValidationWarning.new(IRV::NO_ROUND_INFORMATION_WARNING,
+ :results, competition1.id,
round_id: "333oh-f"),
]
expect(irv.errors).to be_empty
@@ -158,8 +158,8 @@
irv = IRV.new.validate(competition_ids: competition1.id)
expected_warnings = [
- RV::ValidationWarning.new(:results, competition1.id,
- IRV::UNDEF_TL_WARNING,
+ RV::ValidationWarning.new(IRV::UNDEF_TL_WARNING,
+ :results, competition1.id,
round_id: "333oh-f"),
]
expect(irv.errors).to be_empty
@@ -179,8 +179,8 @@
result_kind = model.model_name.singular.to_sym
FactoryBot.create(result_kind, competition: competition1, eventId: "444")
res_ko = FactoryBot.create(result_kind, :skip_validation, :mo3, competition: competition1, eventId: "444", skip_round_creation: true)
- errs[model.to_s] << RV::ValidationError.new(:results, competition1.id,
- IRV::MISMATCHED_RESULT_FORMAT_ERROR,
+ errs[model.to_s] << RV::ValidationError.new(IRV::MISMATCHED_RESULT_FORMAT_ERROR,
+ :results, competition1.id,
round_id: "444-f",
person_name: res_ko.personName,
expected_format: "Average of 5",
@@ -215,23 +215,23 @@
res_mbf = FactoryBot.create(result_kind, :mbf, competition: competition1)
# 8 points in 60:02 (ie: reached the time limit and got +2)
res_mbf.update(value2: 910_360_200)
- warns << RV::ValidationWarning.new(:results, competition1.id,
- IRV::MBF_RESULT_OVER_TIME_LIMIT_WARNING,
+ warns << RV::ValidationWarning.new(IRV::MBF_RESULT_OVER_TIME_LIMIT_WARNING,
+ :results, competition1.id,
round_id: "333mbf-f",
person_name: res_mbf.personName,
result: res_mbf.solve_times[1].clock_format)
res22 = FactoryBot.create(result_kind, competition: competition2, eventId: "222")
res22.update(value4: -2)
- warns << RV::ValidationWarning.new(:results, competition2.id,
- IRV::RESULT_AFTER_DNS_WARNING,
+ warns << RV::ValidationWarning.new(IRV::RESULT_AFTER_DNS_WARNING,
+ :results, competition2.id,
round_id: "222-f",
person_name: res22.personName)
# This creates the same result row for a different person as res22, expect for the DNS.
res_sim1 = FactoryBot.create(result_kind, competition: competition2, eventId: "222")
- warns << RV::ValidationWarning.new(:results, competition2.id,
- IRV::SIMILAR_RESULTS_WARNING,
+ warns << RV::ValidationWarning.new(IRV::SIMILAR_RESULTS_WARNING,
+ :results, competition2.id,
round_id: "222-f",
person_name: res_sim1.personName,
similar_person_name: res22.personName)
@@ -241,8 +241,8 @@
# already has one DNF which counts towards the cumulative time limit of 2:00.00.
res_bf = FactoryBot.create(result_kind, :blind_dnf_mo3, competition: competition1, best: 100_00, value1: -1)
- warns << RV::ValidationWarning.new(:results, competition1.id,
- IRV::SUSPICIOUS_DNF_WARNING,
+ warns << RV::ValidationWarning.new(IRV::SUSPICIOUS_DNF_WARNING,
+ :results, competition1.id,
round_ids: "333bf-f",
person_name: res_bf.personName)
diff --git a/spec/lib/results_validators/persons_validator_spec.rb b/spec/lib/results_validators/persons_validator_spec.rb
index 90fb892a225..74829cc7b49 100644
--- a/spec/lib/results_validators/persons_validator_spec.rb
+++ b/spec/lib/results_validators/persons_validator_spec.rb
@@ -50,8 +50,8 @@
eventId: "333oh")
res1.person.delete
expected_errors[model.to_s] = [
- RV::ValidationError.new(:persons, competition1.id,
- PV::RESULTS_WITHOUT_PERSON_ERROR,
+ RV::ValidationError.new(PV::RESULTS_WITHOUT_PERSON_ERROR,
+ :persons, competition1.id,
person_id: res1.personId),
]
end
@@ -83,25 +83,25 @@
res1.person.update(dob: 90.years.ago, gender: "a", name: "Hey", countryId: "FR")
expected_warnings = [
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::SAME_PERSON_NAME_WARNING,
+ RV::ValidationWarning.new(PV::SAME_PERSON_NAME_WARNING,
+ :persons, competition1.id,
name: person.name, wca_ids: person.wca_id),
- RV::ValidationWarning.new(:persons, competition2.id,
- PV::NON_MATCHING_DOB_WARNING,
+ RV::ValidationWarning.new(PV::NON_MATCHING_DOB_WARNING,
+ :persons, competition2.id,
name: res1.person.name, wca_id: person.wca_id,
expected_dob: person.dob,
dob: res1.person.dob),
- RV::ValidationWarning.new(:persons, competition2.id,
- PV::NON_MATCHING_NAME_WARNING,
+ RV::ValidationWarning.new(PV::NON_MATCHING_NAME_WARNING,
+ :persons, competition2.id,
name: res1.person.name, wca_id: person.wca_id,
expected_name: person.name),
- RV::ValidationWarning.new(:persons, competition2.id,
- PV::NON_MATCHING_GENDER_WARNING,
+ RV::ValidationWarning.new(PV::NON_MATCHING_GENDER_WARNING,
+ :persons, competition2.id,
name: res1.person.name, wca_id: person.wca_id,
expected_gender: person.gender,
gender: res1.person.gender),
- RV::ValidationWarning.new(:persons, competition2.id,
- PV::NON_MATCHING_COUNTRY_WARNING,
+ RV::ValidationWarning.new(PV::NON_MATCHING_COUNTRY_WARNING,
+ :persons, competition2.id,
name: res1.person.name, wca_id: person.wca_id,
expected_country: person.country.iso2,
country: res1.person.country.iso2),
@@ -121,9 +121,9 @@
# PERSON_WITHOUT_RESULTS_ERROR
# WRONG_WCA_ID_ERROR
# WRONG_PARENTHESIS_FORMAT_ERROR
- # DOB_0101_WARNING
- # VERY_YOUNG_PERSON_WARNING
- # NOT_SO_YOUNG_PERSON_WARNING
+ # DOB_JAN_ONE
+ # DOB_TOO_YOUNG
+ # DOB_TOO_OLD
# EMPTY_GENDER_WARNING
# WHITESPACE_IN_NAME_ERROR
# WRONG_PARENTHESIS_TYPE_ERROR
@@ -194,63 +194,63 @@
res_wrong_wca_id.person.update(wcaId: "ERR")
expected_errors = [
- RV::ValidationError.new(:persons, competition2.id,
- PV::PERSON_WITHOUT_RESULTS_ERROR,
+ RV::ValidationError.new(PV::PERSON_WITHOUT_RESULTS_ERROR,
+ :persons, competition2.id,
person_name: res1.person.name,
person_id: res1.person.id),
- RV::ValidationError.new(:persons, competition1.id,
- PV::WHITESPACE_IN_NAME_ERROR,
+ RV::ValidationError.new(PV::WHITESPACE_IN_NAME_ERROR,
+ :persons, competition1.id,
name: res_whitespace.person.name),
- RV::ValidationError.new(:persons, competition1.id,
- PV::WRONG_WCA_ID_ERROR,
+ RV::ValidationError.new(PV::WRONG_WCA_ID_ERROR,
+ :persons, competition1.id,
name: res_wrong_wca_id.person.name,
wca_id: res_wrong_wca_id.person.wca_id),
- RV::ValidationError.new(:persons, competition1.id,
- PV::WRONG_PARENTHESIS_FORMAT_ERROR,
+ RV::ValidationError.new(PV::WRONG_PARENTHESIS_FORMAT_ERROR,
+ :persons, competition1.id,
name: res_whitespace.person.name),
- RV::ValidationError.new(:persons, competition1.id,
- PV::WRONG_PARENTHESIS_TYPE_ERROR,
+ RV::ValidationError.new(PV::WRONG_PARENTHESIS_TYPE_ERROR,
+ :persons, competition1.id,
name: res_bad_parenthesis.person.name),
]
expected_warnings = [
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::DOB_0101_WARNING,
+ RV::ValidationWarning.new(PV::DOB_JAN_ONE,
+ :persons, competition1.id,
name: res0101.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::VERY_YOUNG_PERSON_WARNING,
+ RV::ValidationWarning.new(PV::DOB_TOO_YOUNG,
+ :persons, competition1.id,
name: res_too_young.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::NOT_SO_YOUNG_PERSON_WARNING,
+ RV::ValidationWarning.new(PV::DOB_TOO_OLD,
+ :persons, competition1.id,
name: res_not_young.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::EMPTY_GENDER_WARNING,
+ RV::ValidationWarning.new(PV::EMPTY_GENDER_WARNING,
+ :persons, competition1.id,
name: res_whitespace.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING,
+ RV::ValidationWarning.new(PV::MULTIPLE_NEWCOMERS_WITH_SAME_NAME_WARNING,
+ :persons, competition1.id,
name: res_same_name1.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::LOWERCASE_NAME_WARNING,
+ RV::ValidationWarning.new(PV::LOWERCASE_NAME_WARNING,
+ :persons, competition1.id,
name: res_lowercase1.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::LOWERCASE_NAME_WARNING,
+ RV::ValidationWarning.new(PV::LOWERCASE_NAME_WARNING,
+ :persons, competition1.id,
name: res_lowercase2.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::UPPERCASE_NAME_WARNING,
+ RV::ValidationWarning.new(PV::UPPERCASE_NAME_WARNING,
+ :persons, competition1.id,
name: res_bad_period_upcase.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::LETTER_AFTER_PERIOD_WARNING,
+ RV::ValidationWarning.new(PV::LETTER_AFTER_PERIOD_WARNING,
+ :persons, competition1.id,
name: res_bad_period_upcase.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::MISSING_PERIOD_WARNING,
+ RV::ValidationWarning.new(PV::MISSING_PERIOD_WARNING,
+ :persons, competition1.id,
name: res_missing_period.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING,
+ RV::ValidationWarning.new(PV::SINGLE_LETTER_FIRST_OR_LAST_NAME_WARNING,
+ :persons, competition1.id,
name: res_single_letter.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::SINGLE_NAME_WARNING,
+ RV::ValidationWarning.new(PV::SINGLE_NAME_WARNING,
+ :persons, competition1.id,
name: res_same_name1.person.name),
- RV::ValidationWarning.new(:persons, competition1.id,
- PV::SINGLE_NAME_WARNING,
+ RV::ValidationWarning.new(PV::SINGLE_NAME_WARNING,
+ :persons, competition1.id,
name: res_same_name2.person.name),
]
validator_args = [
diff --git a/spec/lib/results_validators/positions_validator_spec.rb b/spec/lib/results_validators/positions_validator_spec.rb
index 9d30930ba19..c33b13422b5 100644
--- a/spec/lib/results_validators/positions_validator_spec.rb
+++ b/spec/lib/results_validators/positions_validator_spec.rb
@@ -65,14 +65,14 @@
personName1 = table_results[0].first.personName
personName2 = table_results[1].last.personName
expected_infos[model.to_s] = [
- ResultsValidators::ValidationInfo.new(:results, competition1.id,
- ResultsValidators::PositionsValidator::POSITION_FIXED_INFO,
+ ResultsValidators::ValidationInfo.new(ResultsValidators::PositionsValidator::POSITION_FIXED_INFO,
+ :results, competition1.id,
round_id: "333oh-f",
person_name: personName1,
expected_pos: 1,
pos: 2),
- ResultsValidators::ValidationInfo.new(:results, competition2.id,
- ResultsValidators::PositionsValidator::POSITION_FIXED_INFO,
+ ResultsValidators::ValidationInfo.new(ResultsValidators::PositionsValidator::POSITION_FIXED_INFO,
+ :results, competition2.id,
round_id: "222-f",
person_name: personName2,
expected_pos: 5,
@@ -174,5 +174,5 @@ def create_incorrect_tied_results(competition, event_id, kind: :result)
end
def create_result_error(competition_id, round_id, name, expected_pos, actual_pos)
- ResultsValidators::ValidationError.new(:results, competition_id, ResultsValidators::PositionsValidator::WRONG_POSITION_IN_RESULTS_ERROR, round_id: round_id, person_name: name, expected_pos: expected_pos, pos: actual_pos)
+ ResultsValidators::ValidationError.new(ResultsValidators::PositionsValidator::WRONG_POSITION_IN_RESULTS_ERROR, :results, competition_id, round_id: round_id, person_name: name, expected_pos: expected_pos, pos: actual_pos)
end
diff --git a/spec/lib/results_validators/scrambles_validator_spec.rb b/spec/lib/results_validators/scrambles_validator_spec.rb
index 5488e564966..4b13c83b74f 100644
--- a/spec/lib/results_validators/scrambles_validator_spec.rb
+++ b/spec/lib/results_validators/scrambles_validator_spec.rb
@@ -38,11 +38,11 @@
end
expected_errors = [
- RV::ValidationError.new(:scrambles, competition1.id,
- SV::UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR,
+ RV::ValidationError.new(SV::UNEXPECTED_SCRAMBLES_FOR_ROUND_ERROR,
+ :scrambles, competition1.id,
round_id: "333-f"),
- RV::ValidationError.new(:scrambles, competition2.id,
- SV::MISSING_SCRAMBLES_FOR_ROUND_ERROR,
+ RV::ValidationError.new(SV::MISSING_SCRAMBLES_FOR_ROUND_ERROR,
+ :scrambles, competition2.id,
round_id: "333bf-f"),
]
@@ -68,11 +68,11 @@
create_scramble_set(2, competitionId: competition2.id, eventId: "333bf")
expected_errors = [
- RV::ValidationError.new(:scrambles, competition1.id,
- SV::MISSING_SCRAMBLES_FOR_COMPETITION_ERROR,
+ RV::ValidationError.new(SV::MISSING_SCRAMBLES_FOR_COMPETITION_ERROR,
+ :scrambles, competition1.id,
competition_id: competition1.id),
- RV::ValidationError.new(:scrambles, competition2.id,
- SV::MISSING_SCRAMBLES_FOR_GROUP_ERROR,
+ RV::ValidationError.new(SV::MISSING_SCRAMBLES_FOR_GROUP_ERROR,
+ :scrambles, competition2.id,
round_id: "333bf-f", group_id: "A",
actual: 2, expected: 3),
]
@@ -98,8 +98,8 @@
create_scramble_set(5, competitionId: competition1.id, eventId: "333oh", groupId: "C")
expected_errors = [
- RV::ValidationError.new(:scrambles, competition1.id,
- SV::WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR,
+ RV::ValidationError.new(SV::WRONG_NUMBER_OF_SCRAMBLE_SETS_ERROR,
+ :scrambles, competition1.id,
round_id: "333oh-f"),
]
@@ -123,8 +123,8 @@
create_scramble_set(3, competitionId: competition3.id, eventId: "333fm", groupId: "B")
expected_warnings = [
- RV::ValidationWarning.new(:scrambles, competition3.id,
- SV::MULTIPLE_FMC_GROUPS_WARNING,
+ RV::ValidationWarning.new(SV::MULTIPLE_FMC_GROUPS_WARNING,
+ :scrambles, competition3.id,
round_id: "333fm-f"),
]
@@ -156,8 +156,8 @@
create_scramble_set(2, competitionId: competition2.id, eventId: "333mbf", groupId: "B")
expected_errors = [
- RV::ValidationError.new(:scrambles, competition2.id,
- SV::MISSING_SCRAMBLES_FOR_MULTI_ERROR,
+ RV::ValidationError.new(SV::MISSING_SCRAMBLES_FOR_MULTI_ERROR,
+ :scrambles, competition2.id,
round_id: "333mbf-f"),
]