2024-03-23 15:29:55 -04:00
|
|
|
class StatsController < ApplicationController
|
|
|
|
|
before_action :authenticate_user!
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@stats = current_user.stats.group_by(&:year).sort_by { _1 }.reverse
|
|
|
|
|
end
|
2024-03-24 14:25:33 -04:00
|
|
|
|
2024-03-24 14:46:55 -04:00
|
|
|
def show
|
|
|
|
|
@year = params[:year].to_i
|
2024-03-28 10:11:59 -04:00
|
|
|
@stats = current_user.stats.where(year: @year).order(:month)
|
2024-03-24 14:46:55 -04:00
|
|
|
end
|
|
|
|
|
|
2024-03-24 14:25:33 -04:00
|
|
|
def update
|
|
|
|
|
StatCreatingJob.perform_later(current_user.id)
|
|
|
|
|
|
|
|
|
|
redirect_to stats_path, notice: 'Stats are being updated', status: :see_other
|
|
|
|
|
end
|
2024-03-23 15:29:55 -04:00
|
|
|
end
|