@@ -8,7 +8,6 @@ class Repository
8
8
include PactBroker ::Repositories ::Helpers
9
9
include PactBroker ::Repositories
10
10
11
- # TODO SORT BY MOST RECENT FIRST
12
11
# TODO move latest verification logic in to database
13
12
14
13
GROUP_BY_PROVIDER_VERSION_NUMBER = [ :consumer_name , :consumer_version_number , :provider_name , :provider_version_number ]
@@ -43,7 +42,7 @@ def apply_scope options, selectors, lines
43
42
44
43
lines . group_by { |line | group_by_columns . collect { |key | line . send ( key ) } }
45
44
. values
46
- . collect { | lines | lines . first . provider_version_number . nil? ? lines : lines . last }
45
+ . collect { | lines | lines . first . provider_version_number . nil? ? lines : lines . first }
47
46
. flatten
48
47
end
49
48
@@ -53,8 +52,7 @@ def find_for_consumer_and_provider pacticipant_1_name, pacticipant_2_name
53
52
end
54
53
55
54
def find_compatible_pacticipant_versions selectors
56
- find ( selectors , latestby : 'cvpv' )
57
- . select { |line | line [ :success ] }
55
+ find ( selectors , latestby : 'cvpv' ) . select { |line | line [ :success ] }
58
56
end
59
57
60
58
##
@@ -70,11 +68,14 @@ def find_all selectors, options
70
68
query = where_consumer_and_provider_in ( selectors , query )
71
69
end
72
70
73
- # TODO need to order by most recent first, otherwise the limit will give us the oldest rows
74
-
75
71
query = query . limit ( options [ :limit ] ) if options [ :limit ]
76
-
77
- query . order ( :verification_executed_at , :verification_id ) . all
72
+ query . order (
73
+ Sequel . asc ( :consumer_name ) ,
74
+ Sequel . desc ( :consumer_version_order ) ,
75
+ Sequel . desc ( :pact_revision_number ) ,
76
+ Sequel . asc ( :provider_name ) ,
77
+ Sequel . desc ( :provider_version_order ) ,
78
+ Sequel . desc ( :verification_id ) ) . all
78
79
end
79
80
80
81
def base_table ( options )
0 commit comments