Skip to content

Instantly share code, notes, and snippets.

@bhfailor
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhfailor/9421625 to your computer and use it in GitHub Desktop.
Save bhfailor/9421625 to your computer and use it in GitHub Desktop.
compare event_registrations and team_entries record counts for team_id 22101
# Want to know what status values are present in what numbers
sc = {}
team22101 = "team_id = 22101"
TeamEntry.find(:all, conditions: team22101).each do |te|
s = EventRegistration.find(te.event_registration_id).status
if sc[s] == nil then sc[s] = 1 else sc[s] += 1 end
end
# sc => {"Trash"=>31, "Complete"=>640, "rm_pending"=>25, nil=>4, "Expired"=>6}
# Want to know what status values are present in what numbers
scev = {}
team22101 = "team_id = 22101"
EventRegistration.find(:all, conditions: team22101).each do |ev|
s = ev.status
if scev[s] == nil then scev[s] = 1 else scev[s] += 1 end
end
# scev => {"Expired"=>72, "Trash"=>32, "Complete"=>638, "rm_pending"=>25, nil=>4}
# Capture an array of registration numbers this time
scrn = {}
team22101 = "team_id = 22101"
TeamEntry.find(:all, conditions: team22101).each do |te|
s = EventRegistration.find(te.event_registration_id).status
if scrn[s] == nil then scrn[s] = [te.event_registration_id] else scrn[s] << [te.event_registration_id] end
end
# scrn.keys => ["Trash", "Complete", "rm_pending", nil, "Expired"]
# scrn["Trash"].uniq.count => 31
# scrn["Complete"].uniq.count => 639 <= this is the only status that has a repeated event_registration_id
# scrn["Expired"].uniq.count => 6
# scrn["rm_pending"].uniq.count => 25
# scrn[nil].uniq.count => 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment