| Class | ResultsController |
| In: |
app/controllers/results_controller.rb
|
| Parent: | ApplicationController |
What appear to be duplicate finds are actually existence tests. Many methods to handle old URLs that search engines still hit. Will be removed.
# File app/controllers/results_controller.rb, line 41
41: def event
42: @event = Event.find(params[:event_id])
43:
44: case @event
45: when AgeGradedBar, Bar, TeamBar
46: return redirect_to(:controller => 'bar', :action => 'show', :year => @event.year, :discipline => @event.discipline)
47: when Cat4WomensRaceSeries
48: return redirect_to(cat4_womens_race_series_path(:year => @event.year))
49: when OverallBar
50: return redirect_to(:controller => 'bar', :action => 'show', :year => @event.year)
51: when Ironman
52: return redirect_to(ironman_path(:year => @event.year))
53: when OregonCup
54: return redirect_to(oregon_cup_path(:year => @event.year))
55: when RiderRankings
56: return redirect_to(rider_rankings_path(:year => @event.year))
57: end
58:
59: ResultsController::benchmark "Load results", Logger::DEBUG, false do
60: @event = Event.find(
61: params[:event_id],
62: :include => [ :races => [ :category, { :results => :team } ] ]
63: )
64: end
65:
66: expires_in 1.hour, :public => true
67: end
HTML: Formatted links to Events with Results
JSON, XML: Remote API
JSON and XML results are paginated with a page size of 10
:place_in_category, :points, :points_from_place, :points_bonus_penalty, :points_total, :state, :time, :time_gap_to_leader, :time_gap_to_previous, :time_gap_to_winner, :laps, :points_bonus, :points_penalty, :preliminary, :gender, :category_class, :age_group, :custom_attributes ]
See source code of Api::Results and Api::Base
# File app/controllers/results_controller.rb, line 25
25: def index
26: expires_in 1.hour, :public => true
27: respond_to do |format|
28: format.html {
29: @year = params['year'].to_i
30: @year = Date.today.year if @year == 0
31: @discipline = Discipline[params['discipline']]
32: @discipline_names = Discipline.find_all_names
33: @weekly_series, @events, @competitions = Event.find_all_with_results(@year, @discipline)
34: }
35: format.xml { render :xml => results_as_xml }
36: format.json { render :json => results_as_json }
37: end
38: end
Person‘s Results for an entire year
# File app/controllers/results_controller.rb, line 95
95: def person
96: @person = Person.find(params[:person_id])
97: set_date_and_year
98: @event_results = Result.find(
99: :all,
100: :conditions => [ "person_id = ? and year = ? and competition_result = false and team_competition_result = false", @person.id, @date.year ]
101: )
102: @competition_results = Result.find(
103: :all,
104: :include => { :scores => [ :source_result, :competition_result ] },
105: :conditions => [ "person_id = ? and year = ? and (competition_result = true or team_competition_result = true)", @person.id, @date.year ]
106: )
107: expires_in 1.hour, :public => true
108: render :layout => !request.xhr?
109: end
Single Person‘s Results for a single Event
# File app/controllers/results_controller.rb, line 70
70: def person_event
71: @event = Event.find(params[:event_id])
72: @person = Person.find(params[:person_id])
73: @results = Result.find(
74: :all,
75: :include => { :scores => [ :source_result, :competition_result ] },
76: :conditions => ['results.event_id = ? and person_id = ?', params[:event_id], params[:person_id]]
77: )
78: expires_in 1.hour, :public => true
79: end
Teams‘s Results for an entire year
# File app/controllers/results_controller.rb, line 112
112: def team
113: @team = Team.find(params[:team_id])
114: set_date_and_year
115: @results = Result.find(
116: :all,
117: :conditions => [ "team_id = ? and year = ? and competition_result = false and team_competition_result = false", @team.id, @date.year ]
118: )
119: expires_in 1.hour, :public => true
120: end
Single Team‘s Results for a single Event
# File app/controllers/results_controller.rb, line 82
82: def team_event
83: @team = Team.find(params[:team_id])
84: @event = Event.find(params[:event_id])
85: @result = Result.find(
86: :first,
87: :include => { :scores => [ :source_result, :competition_result ] },
88: :conditions => ['results.event_id = ? and team_id = ? and race_id = ?', params[:event_id], params[:team_id], params[:race_id]]
89: )
90: raise ActiveRecord::RecordNotFound unless @result
91: expires_in 1.hour, :public => true
92: end