Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Created a rake task to set problem.next_problem

  • Loading branch information...
commit 0c3db08f7cd0b4e572bce3aa8e00704d78cba2b4 1 parent 090b78a
David Davis authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/tasks/problems.rake
9 lib/tasks/problems.rake
View
@@ -18,4 +18,13 @@ namespace :problems do
end
puts "Updated #{count} problems"
end
+
+ task :link => :environment do
+ problems = Problem.approved.all.sort_by {|p| [p.difficulty, (-1 * p.solutions.count)]}
+
+ problems.each_with_index do |problem, i|
+ problem.next_problem = problems[i+1] if problems[i+1]
+ problem.save!
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.