Merge branch 'master' into fix-for-ransack-deprecated-method

This commit is contained in:
Dinar Safiulin 2021-09-14 13:50:18 +03:00 committed by GitHub
commit 9cafc98482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
171 changed files with 1061 additions and 726 deletions

View file

@ -3,19 +3,27 @@ module Admin
load_and_authorize_resource class: ApiLog::ReppLog
before_action :set_default_dates, only: [:index]
# rubocop:disable Metrics/MethodLength
def index
@q = ApiLog::ReppLog.ransack(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@repp_logs = @q.result
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present?
if params[:q][:created_at_gteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_gteq]))
end
if params[:q][:created_at_lteq].present?
@repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
Time.parse(params[:q][:created_at_lteq]))
end
@repp_logs = @repp_logs.page(params[:page])
@count = @q.result.count
@repp_logs = @repp_logs.per(params[:results_per_page]) if paginate?
render_by_format('admin/repp_logs/index', 'repp_logs')
end
# rubocop:enable Metrics/MethodLength
def show
@repp_log = ApiLog::ReppLog.find(params[:id])