Skip to content

Commit f6f8fb2

Browse files
committed
feat(dashboard): sort items by most recent activity
1 parent 8b9f953 commit f6f8fb2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/pact_broker/api/decorators/dashboard_decorator.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ def to_hash(options)
2626
attr_reader :index_items
2727

2828
def items(index_items, base_url)
29-
index_items.collect do | index_item |
29+
sorted_index_items.collect do | index_item |
3030
index_item_hash(index_item.consumer, index_item.provider, index_item.consumer_version, index_item, base_url)
3131
end
3232
end
3333

34+
def sorted_index_items
35+
index_items.sort{ |i1, i2| i2.last_activity_date <=> i1.last_activity_date }
36+
end
37+
3438
def index_item_hash(consumer, provider, consumer_version, index_item, base_url)
3539
{
3640
consumer: consumer_hash(index_item, consumer, consumer_version, base_url),

lib/pact_broker/domain/index_item.rb

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ def to_a
135135
[consumer, provider]
136136
end
137137

138+
def last_activity_date
139+
@last_activity_date ||= [latest_pact.created_at, latest_verification ? latest_verification.execution_date : nil].compact.max
140+
end
138141
end
139142
end
140143
end

0 commit comments

Comments
 (0)