Apply automatic rubocop fixes
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StatisticsController < ApplicationController
|
||||
include StatisticsHelper
|
||||
|
||||
before_action :authorize!, only: [:show, :graphs, :user_activity, :user_activity_history, :rfc_activity,
|
||||
:rfc_activity_history]
|
||||
before_action :authorize!, only: %i[show graphs user_activity user_activity_history rfc_activity
|
||||
rfc_activity_history]
|
||||
|
||||
def policy_class
|
||||
StatisticsPolicy
|
||||
@ -15,8 +17,7 @@ class StatisticsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def graphs
|
||||
end
|
||||
def graphs; end
|
||||
|
||||
def user_activity
|
||||
respond_to do |format|
|
||||
@ -27,7 +28,7 @@ class StatisticsController < ApplicationController
|
||||
def user_activity_history
|
||||
respond_to do |format|
|
||||
format.html { render('activity_history', locals: {resource: :user}) }
|
||||
format.json { render_ranged_data :ranged_user_data}
|
||||
format.json { render_ranged_data :ranged_user_data }
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,14 +47,21 @@ class StatisticsController < ApplicationController
|
||||
|
||||
def render_ranged_data(data_source)
|
||||
interval = params[:interval].to_s.empty? ? 'year' : params[:interval]
|
||||
from = DateTime.strptime(params[:from], '%Y-%m-%d') rescue DateTime.new(0)
|
||||
to = DateTime.strptime(params[:to], '%Y-%m-%d') rescue DateTime.now
|
||||
render(json: self.send(data_source, interval, from, to))
|
||||
from = begin
|
||||
DateTime.strptime(params[:from], '%Y-%m-%d')
|
||||
rescue StandardError
|
||||
DateTime.new(0)
|
||||
end
|
||||
to = begin
|
||||
DateTime.strptime(params[:to], '%Y-%m-%d')
|
||||
rescue StandardError
|
||||
DateTime.now
|
||||
end
|
||||
render(json: send(data_source, interval, from, to))
|
||||
end
|
||||
|
||||
def authorize!
|
||||
authorize self
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user