Skip to content

Instantly share code, notes, and snippets.

@lcowell
Created December 19, 2011 20:02
Show Gist options
  • Save lcowell/1498634 to your computer and use it in GitHub Desktop.
Save lcowell/1498634 to your computer and use it in GitHub Desktop.
# we can name each result set eg. top_male_times_this_season
result
| name |
# it's unlikely that we're going to reuse results, so we should scope them by the result they belong to
results
| age | time | gender | result_id |
| 23 | 55:11 | M | 1 |
| 49 | 1:27:51 | F | 2 |
# with this organization it will be easy to do the following:
result = Result.load(:top, Trail.current) # load the top saved query for the current season
result = Result.load(:top_all_time, Trail.grind) # load the top saved query for the summer season
result.each_gender do |gender|
gender.grinders.each do |grinder|
grinder.name
grinder.time
end
end
result.each_gender do |gender|
gender.each_age_group do |age_group|
age_group.best
age_group.average
age_group.grinders(3) do |grinder|
grinder.name
grinder.time
end
end
end
result = Result.load(:most_grinds_all_time)
result.genders do |gender|
gender.grinders do |grinder|
grinder.name
grinder.grinds
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment