@@ -13,12 +13,17 @@ class Service
13
13
extend PactBroker ::Services
14
14
extend PactBroker ::Logging
15
15
16
+ # This method provides data for both the OSS server side rendered index (with and without tags)
17
+ # and the Pactflow UI. It really needs to be broken into to separate methods, as it's getting too messy
18
+ # supporting both
19
+
16
20
def self . find_index_items options = { }
17
21
rows = PactBroker ::Matrix ::HeadRow
18
22
. select_all_qualified
19
23
. eager ( :latest_triggered_webhooks )
20
24
. eager ( :webhooks )
21
25
26
+ # pactflow
22
27
rows = rows . consumer ( options [ :consumer_name ] ) if options [ :consumer_name ]
23
28
rows = rows . provider ( options [ :provider_name ] ) if options [ :provider_name ]
24
29
@@ -29,9 +34,17 @@ def self.find_index_items options = {}
29
34
rows = rows . where ( consumer_version_tag_name : options [ :tags ] ) . or ( consumer_version_tag_name : nil )
30
35
end
31
36
rows = rows . eager ( :consumer_version_tags )
32
- . eager ( :provider_version_tags )
33
- . eager ( :latest_verification_for_consumer_version_tag )
34
- . eager ( :latest_verification_for_consumer_and_provider )
37
+ . eager ( :provider_version_tags )
38
+
39
+ if !options [ :dashboard ] # pactflow
40
+ # The latest_verification_for_consumer_version_tag query is very slow when there is lots of data,
41
+ # and it is only used when calculating latest_verification_for_pseudo_branch,
42
+ # so only load it if we need it
43
+ rows = rows . eager ( :latest_verification_for_consumer_version_tag )
44
+ . eager ( :latest_verification_for_consumer_and_provider )
45
+ end
46
+
47
+
35
48
end
36
49
rows = rows . all . group_by ( &:pact_publication_id ) . values . collect { | rows | Matrix ::AggregatedRow . new ( rows ) }
37
50
@@ -45,7 +58,7 @@ def self.find_index_items options = {}
45
58
# or it's not verified.
46
59
# For backwards compatiblity with the existing UI, don't change the 'stale' concept for the OSS
47
60
# UI - just ensure we don't use it for the new dashboard endpoint with the consumer/provider specified.
48
- latest_verification = if options [ :dashboard ]
61
+ latest_verification = if options [ :dashboard ] # pactflow
49
62
row . latest_verification_for_pact_version
50
63
else
51
64
row . latest_verification_for_pseudo_branch
0 commit comments