Merge pull request #2574 from internetee/2568-fix-epp-log-records-sorting

Fixed default sorting of epp logs
This commit is contained in:
Timo Võhmar 2023-05-18 11:24:25 +03:00 committed by GitHub
commit 1a00e9c782
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View file

@ -6,16 +6,16 @@ module Admin
# rubocop:disable Metrics/MethodLength
def index
@q = ApiLog::EppLog.ransack(PartialSearchFormatter.format(params[:q]))
@result = @q.result
@q.sorts = 'id desc' if @q.sorts.empty?
@result = @q.result
@epp_logs = @result
if params[:q][:created_at_gteq].present?
@epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)",
@epp_logs = @epp_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?
@epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)",
@epp_logs = @epp_logs.where('extract(epoch from created_at) <= extract(epoch from ?::timestamp)',
Time.parse(params[:q][:created_at_lteq]))
end
@epp_logs = @epp_logs.page(params[:page])
@ -35,7 +35,7 @@ module Admin
default_date = params[:created_after]
default_date = 'today' unless %w[today tomorrow yesterday].include?(default_date)
params[:q][:created_at_gteq] = Date.send(default_date).strftime("%Y-%m-%d")
params[:q][:created_at_gteq] = Date.send(default_date).strftime('%Y-%m-%d')
end
private

View file

@ -17,7 +17,7 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase
send_epp_request_hello
visit admin_epp_logs_path
find(:xpath, "//tbody/tr/td/a", match: :first).click
find(:xpath, '//tbody/tr/td/a', match: :first).click
assert_text 'Details'
end
@ -27,12 +27,14 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase
send_epp_request_hello
visit admin_epp_logs_path
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
epp_log_date = find(:xpath, "//table/tbody/tr/td[6]", match: :first).text(:all)
date_now = Date.today.to_s(:db)
epp_log_date = find(:xpath, '//table/tbody/tr/td[6]', match: :first).text(:all)
assert_match /#{date_now}/, epp_log_date
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
find(:xpath, "//a[contains(text(), 'Created at')]", match: :first).click
epp_log_date = find(:xpath, '//table/tbody/tr/td[6]', match: :first).text(:all)
assert_match /#{date_now}/, epp_log_date
end
@ -57,9 +59,9 @@ class AdminEppLogsIntegrationTest < ApplicationSystemTestCase
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<hello/>
</epp>
XML
XML
get epp_hello_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
end
end