Skip to content

Commit

Permalink
Update stats_controller.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthillson committed Oct 3, 2024
1 parent 7de3d73 commit f1f7c77
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions app/controllers/admin/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
module Admin
class StatsController < Admin::AdminController
def index
@chart_data = []
Discipline.pluck(:name).each do |discipline|
@chart_data.push({ name: discipline, data: [] })
end
@years = %w[2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024]
@years.each do |year|
res = Result.joins(:event).where(events: { year: year, type: "SingleDayEvent" })
.where(competition_result: false, team_competition_result: false)
.where.not(person_id: nil).group(:discipline).count
@chart_data.each do |data|
if res[data[:name]].nil?
data[:data].push(0)
else
data[:data].push(res[data[:name]])
end
end
end
@chart_data = Stats.racer_days_by_discipline(@years)
end
end
end

0 comments on commit f1f7c77

Please sign in to comment.