From 75d3580207cb02c0fc55f85af3d8ba96cd7a4e60 Mon Sep 17 00:00:00 2001 From: eraffel-MDSol Date: Thu, 29 Aug 2019 20:08:05 -0400 Subject: [PATCH] fix(index): sort pact publication by date, not string Use data-text attribute with date converted to integer to properly sort column --- lib/pact_broker/ui/view_models/index_item.rb | 4 ++++ lib/pact_broker/ui/views/index/show.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/ui/view_models/index_item.rb b/lib/pact_broker/ui/view_models/index_item.rb index 232c31b34..848a614c8 100644 --- a/lib/pact_broker/ui/view_models/index_item.rb +++ b/lib/pact_broker/ui/view_models/index_item.rb @@ -131,6 +131,10 @@ def publication_date_of_latest_pact PactBroker::DateHelper.distance_of_time_in_words(date, DateTime.now) + " ago" end + def publication_date_of_latest_pact_order + @relationship.latest_pact.created_at.to_time.to_i + end + def verification_status case @relationship.verification_status when :success then "success" diff --git a/lib/pact_broker/ui/views/index/show.haml b/lib/pact_broker/ui/views/index/show.haml index 40e48fcf7..a37003686 100644 --- a/lib/pact_broker/ui/views/index/show.haml +++ b/lib/pact_broker/ui/views/index/show.haml @@ -42,7 +42,7 @@ %a{ href: index_item.provider_group_url } = escape_html(index_item.provider_name) %td - %td + %td{"data-text": index_item.publication_date_of_latest_pact_order} = index_item.publication_date_of_latest_pact %td{class: index_item.webhook_status} %a{ href: index_item.webhook_url }