dawarich/app/controllers/stats_controller.rb

24 lines
700 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
@points_total = current_user.tracked_points.count
@points_reverse_geocoded = current_user.total_reverse_geocoded_points
@points_reverse_geocoded_without_data = current_user.total_reverse_geocoded_points_without_data
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