dawarich/app/controllers/stats_controller.rb

21 lines
472 B
Ruby
Raw Normal View History

# frozen_string_literal: true
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.reverse
2024-03-23 15:29:55 -04:00
end
2024-03-24 14:25:33 -04:00
def show
@year = params[:year].to_i
@stats = current_user.stats.where(year: @year).order(:month)
end
2024-03-24 14:25:33 -04:00
def update
Stats::CalculatingJob.perform_later(current_user.id)
2024-03-24 14:25:33 -04:00
redirect_to stats_path, notice: 'Stats are being updated', status: :see_other
end
2024-03-23 15:29:55 -04:00
end