Skip to content

Instantly share code, notes, and snippets.

@bhfailor
bhfailor / piggyback_cleanupRevA.rb
Last active August 29, 2015 13:56
Snippet that identifies unprocessed piggyback registrations and then corrects them
# Check all the possible events for troubled piggybacks
parent_problematic = [] # collect all event registrations independent of the event
[34541, 33921, 24391, 34931, 33821, 34221, 35091, 17891, 34071, 35291, 34611, 34051, 31391, 37821].each do |ev_id|
Event.find(ev_id).event_registrations.where("parent_registration_id IS NOT NULL").map{|r|
r.parent_registration_id}.uniq.each do |parent_registration_id|
parent_registration = nil
begin
parent_registration = EventRegistration.find(parent_registration_id)
rescue
#break
@bhfailor
bhfailor / FirstAirbrakeError
Last active August 29, 2015 13:57
ArgumentErrorsAirbrake
2014-03-07T12:40:42.252957+00:00 app[web.3]: Started GET "/register/disclaimers" for 76.24.37.24 at 2014-03-07 07:40:42 -0500
2014-03-07T12:40:41.995705+00:00 app[web.1]: Started POST "/register/athlete_info" for 76.24.37.24 at 2014-03-07 07:40:41 -0500
2014-03-07T12:40:48.642850+00:00 app[web.1]: Started POST "/register/disclaimers" for 76.24.37.24 at 2014-03-07 07:40:48 -0500
2014-03-07T12:40:48.865051+00:00 app[web.2]: Started GET "/register/payment" for 76.24.37.24 at 2014-03-07 07:40:48 -0500
2014-03-07T12:40:48.723216+00:00 heroku[router]: at=info method=POST path=/register/disclaimers host=www.racemenu.com request_id=b22264d9-af04-4c40-8f3a-c3b6c4026360 fwd="76.24.37.24" dyno=web.1 connect=2ms service=161ms status=302 bytes=462
2014-03-07T12:40:59.533612+00:00 app[web.3]: Started GET "/event/start_list/37821?page=1&sort=bib_number+ASC" for 66.249.66.82 at 2014-03-07 07:40:59 -0500
2014-03-07T12:40:59.871742+00:00 heroku[router]: at=info method=GET path=/event/start_list/37821?page=1&sort=bib_number+ASC
@bhfailor
bhfailor / gist:9421625
Last active August 29, 2015 13:57
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
@bhfailor
bhfailor / gist:9612692
Created March 18, 2014 02:50
fee calculation
class RegisterController < ApplicationController
# many lines deleted
def payment
# If there are no registrations done, go back to the athlete info page and start over
if session[:reg_ids].nil? or session[:reg_ids].blank?
redirect_to :action => 'athlete_info'
end
@reg = EventRegistration.find(session[:reg_ids].first) # assign the first EventRegistration object to @reg so it will be available in the view
@race = Race.find(session[:race] ) # assign the value of @race to the Race object with id equal to the value of the session key :race so it will be available to the view
@bhfailor
bhfailor / gist:9700767
Created March 22, 2014 03:43
notion of code to split a transaction between subevents
ev = Event.find(22651)
regs = ev.event_registrations
ticks = ev.tickets
# hash with reg_id as key and array of subevent_id values
hsh = {}
ticks.each do |tick|
reg_id = tick.event_registration.id
hsh[reg_id] = {} if hsh[reg_id] == nil
if hsh[reg_id][:ri] == nil then hsh[reg_id][:ri] = [tick.race.id] else hsh[reg_id][:ri] << tick.race.id end
if hsh[reg_id][] == nil then hsh[reg_id] = [tick.race.id] else hsh[reg_id] << tick.race.id end
@bhfailor
bhfailor / gist:9792836
Last active August 29, 2015 13:57
Difference between transaction amount and charged amount due to FeeCalculator.service_fee which truncates the service fee
# rails console in the development environment
1.9.3p484 :009 > (10...40).each {|amt| puts "amount #{amt.to_f.round(2)} and charge #{(FeeCalculator.service_fee((amt.to_f-1.0)/1.05)+ (amt.to_f-1.0)/1.05).round(2)}"}
amount 10.0 and charge 9.99
amount 11.0 and charge 10.99
amount 12.0 and charge 12.0
amount 13.0 and charge 13.0
amount 14.0 and charge 13.99
amount 15.0 and charge 14.99
amount 16.0 and charge 16.0
amount 17.0 and charge 17.0
@bhfailor
bhfailor / gist:9842576
Created March 28, 2014 20:43
rake tasks for season pass events and teams
namespace :event do
desc "Add bib #s to event registrations"
task :add_bib => :environment do
event = Event.find(ENV['EVENT'])
resource_file_name = File.join(Rails.root, "lib", "tasks", "event_files", "#{ENV['EVENT']}.csv")
if event.nil?
puts "Unable to find event with id: #{ENV['EVENT']}"
return
@bhfailor
bhfailor / gist:9842884
Last active August 29, 2015 13:57
skype discussion of requirements for season pass processing
[3/28/14 12:35:33 PM] zaeem asif: https://www.racemenu.com/director/39741/registration/teams
https://www.racemenu.com/director/39751/registration/teams
address
[3/28/14 12:40:31 PM] alain - racemenu: https://www.racemenu.com/director/39741/registration/edit_team/25871
[3/28/14 12:41:08 PM] alain - racemenu: https://www.racemenu.com/director/39771/registration/teams
[3/28/14 12:43:07 PM] alain - racemenu: https://www.racemenu.com/director/39741/registration/edit/777061
[3/28/14 12:47:56 PM] alain - racemenu: 2013 HACK SOLUTION:
1) replicated SP team names
@bhfailor
bhfailor / eventmailerinvitation.markdown
Last active September 7, 2017 13:17
eventMailerInvitation
@bhfailor
bhfailor / eventmailerapproved.markdown
Last active September 8, 2017 01:54
eventMailerApproved