Merge pull request #2136 from internetee/2133-fix-for-epplogs-view-loading

Admin:  fix for epp_logs view loading
This commit is contained in:
Timo Võhmar 2021-08-31 14:24:16 +03:00 committed by GitHub
commit 327bf3f001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -4,15 +4,13 @@ module Admin
before_action :set_default_dates, only: [:index]
def index
@q = ApiLog::EppLog.search(params[:q])
@q = ApiLog::EppLog.ransack(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@epp_logs = @q.result
@epp_logs = @epp_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?
@epp_logs = @epp_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?
@epp_logs = @epp_logs.page(params[:page])
@count = @q.result.count
@epp_logs = @epp_logs.per(params[:results_per_page]) if paginate?
render_by_format('admin/epp_logs/index', 'epp_logs')
end

View file

@ -49,7 +49,7 @@
= paginate @epp_logs
.pull-right
.pagination
= t(:result_count, count: @count) if @count > 0
= t(:result_count, count: @epp_logs.total_count) if @epp_logs.total_count.positive?
.row
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
@ -76,4 +76,4 @@
= paginate @epp_logs
.pull-right
.pagination
= t(:result_count, count: @count)
= t(:result_count, count: @epp_logs.total_count) if @epp_logs.total_count.positive?