Skip to content

Instantly share code, notes, and snippets.

@mpartel
Created August 28, 2013 18:28
Show Gist options
  • Save mpartel/6369493 to your computer and use it in GitHub Desktop.
Save mpartel/6369493 to your computer and use it in GitHub Desktop.
TMC speedrun winners query
c = Course.find(21)
available = AvailablePoint.course_points(c).map(&:name).sort
user_times = User.all.map do |u|
pts = u.awarded_points.where(:course_id => c.id).includes(:submission)
raise 'wtf' if pts.uniq != pts
if pts.map(&:name).sort == available
last = pts.map(&:submission).map(&:created_at).max
[u.username, last]
else
nil
end
end.reject(&:nil?).sort_by(&:second)
user_times.size
puts user_times.take(5).join("\n"); nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment