Re-use view for user activity
This commit is contained in:
@ -25,6 +25,10 @@ class StatisticsController < ApplicationController
|
||||
end
|
||||
|
||||
def user_activity_history
|
||||
respond_to do |format|
|
||||
format.html { render('activity_history', locals: {resource: :user}) }
|
||||
format.json { render_ranged_data :ranged_user_data}
|
||||
end
|
||||
end
|
||||
|
||||
def rfc_activity
|
||||
@ -35,16 +39,18 @@ class StatisticsController < ApplicationController
|
||||
|
||||
def rfc_activity_history
|
||||
respond_to do |format|
|
||||
format.html { render 'rfc_activity_history' }
|
||||
format.json do
|
||||
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: ranged_rfc_data(interval, from, to))
|
||||
end
|
||||
format.html { render('activity_history', locals: {resource: :rfc}) }
|
||||
format.json { render_ranged_data :ranged_rfc_data }
|
||||
end
|
||||
end
|
||||
|
||||
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))
|
||||
end
|
||||
|
||||
def authorize!
|
||||
authorize self
|
||||
end
|
||||
|
Reference in New Issue
Block a user