-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7de3d73
commit f1f7c77
Showing
1 changed file
with
1 addition
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |