Skip to content

Commit

Permalink
Add check that person 2’s wca id cannot be older than person 1 (#10350)
Browse files Browse the repository at this point in the history
* Add check that person 2’s wca id cannot be older than person 1

* Update merge_people.rb

* cleaning the mess
  • Loading branch information
lnzainn authored Dec 3, 2024
1 parent 819a3a2 commit b90471c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/merge_people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def person2_must_not_have_associated_user
end
end

validate :person2_year_must_not_be_earlier
def person2_year_must_not_be_earlier
year1 = person1_wca_id[0, 4].to_i
year2 = person2_wca_id[0, 4].to_i
if year2 < year1
errors.add(:person2_wca_id, "WCA ID year cannot be earlier than person1's WCA ID year")
end
end

def do_merge
if !valid?
return false
Expand Down

0 comments on commit b90471c

Please sign in to comment.