mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 02:28:50 +01:00
Add function for updating problem count
This commit is contained in:
@@ -15,4 +15,13 @@ class Problem < ActiveRecord::Base
|
||||
def original_url
|
||||
"https://projecteuler.net/problem=#{self.id}"
|
||||
end
|
||||
|
||||
def self.update_count(new_count)
|
||||
old_count = Problem.count
|
||||
raise ArgumentError, "new count has to be larger than old count" if new_count < old_count
|
||||
|
||||
new_count.times do |i|
|
||||
Problem.where(id: i + 1).first_or_create!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user