Module: PactBroker::Pacts::PactPublicationDatasetModule
Overview
rubocop: disable Metrics/ModuleLength
Instance Method Summary
collapse
-
#consumer_name_like(name) ⇒ Object
-
#consumer_version_number_like(number) ⇒ Object
-
#consumer_version_order_after(order) ⇒ Object
-
#consumer_version_order_before(order) ⇒ Object
-
#consumer_version_tag(tag) ⇒ Object
-
#created_after(date) ⇒ Object
-
#delete ⇒ Object
-
#eager_load_pact_versions ⇒ Object
-
#earliest ⇒ Object
-
#for_all_branch_heads ⇒ Dataset<PactBroker::Pacts::PactPublication>
Returns the pacts (if they exist) for all the branch heads.
-
#for_all_tag_heads ⇒ Sequel::Dataset<PactBroker::Pacts::PactPublication>
The pacts for the latest versions for each tag.
-
#for_branch_heads(branch_name) ⇒ Sequel::Dataset<PactBroker::Pacts::PactPublication>
Return the pacts (if they exist) for the branch heads of the given branch names This uses the new logic of finding the branch head and returning any associated pacts, rather than the old logic of returning the pact for the latest version on the branch that had a pact.
-
#for_branch_name(branch_name) ⇒ Object
-
#for_consumer(consumer) ⇒ Object
-
#for_consumer_id_and_provider_id(consumer_id, provider_id) ⇒ Object
-
#for_consumer_name(consumer_name) ⇒ Object
-
#for_consumer_name_and_maybe_version_number(consumer_name, consumer_version_number) ⇒ Object
-
#for_consumer_version_tag(tag_name) ⇒ Object
-
#for_consumer_version_tag_all_revisions(tag_name) ⇒ Object
-
#for_latest_consumer_versions_with_tag(tag_name) ⇒ Object
The pacts for the latest versions with the specified tag (new logic) NOT the latest pact that belongs to a version with the specified tag.
-
#for_pact_version_id(pact_version_id) ⇒ Object
-
#for_pact_version_sha(pact_version_sha) ⇒ Object
-
#for_provider(provider) ⇒ Object
-
#for_provider_name(provider_name) ⇒ Object
-
#in_environments ⇒ Object
-
#join_consumer_branch_versions ⇒ Object
-
#join_consumer_version_tags(table_alias = :ct) ⇒ Object
-
#join_consumer_version_tags_with_names(consumer_version_tag_names) ⇒ Object
-
#join_consumer_versions(table_alias = :cv, extra_join_criteria = {}, &block) ⇒ Object
-
#join_consumers(table_alias = :consumers, base_table = :pact_publications, extra_join_criteria = {}) ⇒ Object
-
#join_pact_versions ⇒ Object
-
#join_providers(table_alias = :providers, base_table = :pact_publications, extra_join_criteria = {}) ⇒ Object
-
#latest ⇒ Object
-
#latest_by_consumer_branch ⇒ Dataset<PactBroker::Pacts::PactPublication>
Returns the latest pact for each branch, returning a pact for every branch, even if the most recent version of that branch does not have a pact.
-
#latest_by_consumer_tag ⇒ Sequel::Dataset<PactBroker::Pacts::PactPublication>
The latest pact publication for each tag This uses the old logic of “the latest pact for a version that has a tag” (which always returns a pact) rather than “the pact for the latest version with a tag”.
-
#latest_by_consumer_version_order ⇒ Object
-
#latest_for_consumer_branch(branch_name) ⇒ Object
The pact that belongs to the branch head.
-
#latest_for_consumer_tag(tag_name) ⇒ Sequel::Dataset<PactBroker::Pacts::PactPublication>
This uses the old logic of “the latest pact for a version that has a tag” (which always returns a pact) rather than “the pact for the latest version with a tag” Need to see about updating this.
-
#old_latest_for_consumer_branch(branch_name) ⇒ Object
The latest pact that belongs to a version on the specified branch (might not be the version that is the branch head) Always returns a pact, if any pacts exist for this branch.
-
#order_by_consumer_name ⇒ Object
-
#order_by_consumer_version_order ⇒ Object
-
#overall_latest ⇒ Object
-
#overall_latest_for_consumer_id_and_provider_id(consumer_id, provider_id) ⇒ Object
-
#provider_name_like(name) ⇒ Object
-
#remove_overridden_revisions(pact_publications_alias = :pact_publications) ⇒ Object
-
#remove_overridden_revisions_from_complete_query ⇒ Object
-
#tag(tag_name) ⇒ Object
-
#untagged ⇒ Object
-
#verified_before_date(date) ⇒ Object
-
#where_consumer_if_set(consumer) ⇒ Object
#for_currently_deployed_versions, #for_currently_supported_versions, #for_environment, #for_provider_and_consumer_version_selector, #latest_for_main_branches
Instance Method Details
#consumer_name_like(name) ⇒ Object
428
429
430
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 428
def consumer_name_like(name)
where(name_like(Sequel[:consumers][:name], name))
end
|
#consumer_version_number_like(number) ⇒ Object
432
433
434
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 432
def consumer_version_number_like(number)
where(name_like(Sequel[:cv][:number], number))
end
|
#consumer_version_order_after(order) ⇒ Object
444
445
446
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 444
def consumer_version_order_after order
where(Sequel.lit("consumer_version_order > ?", order))
end
|
#consumer_version_order_before(order) ⇒ Object
440
441
442
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 440
def consumer_version_order_before order
where(Sequel.lit("consumer_version_order < ?", order))
end
|
#consumer_version_tag(tag) ⇒ Object
436
437
438
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 436
def consumer_version_tag(tag)
where(name_like(Sequel[:ct][:name],tag))
end
|
#created_after(date) ⇒ Object
334
335
336
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 334
def created_after date
where(Sequel.lit("#{first_source_alias}.created_at > ?", date))
end
|
#delete ⇒ Object
476
477
478
479
480
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 476
def delete
require "pact_broker/webhooks/triggered_webhook"
PactBroker::Webhooks::TriggeredWebhook.where(pact_publication: self).delete
super
end
|
#eager_load_pact_versions ⇒ Object
401
402
403
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 401
def eager_load_pact_versions
eager(:pact_versions)
end
|
#earliest ⇒ Object
460
461
462
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 460
def earliest
order(:consumer_version_order).limit(1)
end
|
Returns the pacts (if they exist) for all the branch heads. If the version for the branch head does not have a pact, then no pact is returned, (unlike latest_by_consumer_branch) This is much more performant than latest_by_consumer_branch and should be used for the ‘pacts for verification’ response
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 127
def for_all_branch_heads
base_query = self
base_query = base_query.join(:branch_heads, { Sequel[:bh][:version_id] => Sequel[:pact_publications][:consumer_version_id] }, { table_alias: :bh })
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:bh][:branch_name].as(:branch_name))
end
base_query.remove_overridden_revisions
end
|
The pacts for the latest versions for each tag. Will not return a pact if the pact is no longer published for a particular tag NEW LOGIC
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 289
def for_all_tag_heads
head_tags = PactBroker::Domain::Tag
.select_group(:pacticipant_id, :name)
.select_append{ max(version_order).as(:latest_version_order) }
head_tags_join = {
Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
end
base_query
.join(head_tags, head_tags_join, { table_alias: :head_tags })
.remove_overridden_revisions_from_complete_query
end
|
Return the pacts (if they exist) for the branch heads of the given branch names This uses the new logic of finding the branch head and returning any associated pacts, rather than the old logic of returning the pact for the latest version on the branch that had a pact.
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 144
def for_branch_heads(branch_name)
branch_head_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_heads][:version_id],
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:branch_heads][:branch_name].as(:branch_name))
end
base_query
.join(:branch_heads, branch_head_join) do
name_like(Sequel[:branch_heads][:branch_name], branch_name)
end
.remove_overridden_revisions_from_complete_query
end
|
#for_branch_name(branch_name) ⇒ Object
410
411
412
413
414
415
416
417
418
419
420
421
422
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 410
def for_branch_name branch_name
branch_versions_join = {
Sequel[:branch_versions][:version_id] => Sequel[:pact_publications][:consumer_version_id],
Sequel[:branch_versions][:branch_name] => branch_name
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:branch_versions][:branch_name].as(:branch_name))
end
base_query.join(:branch_versions, branch_versions_join)
end
|
#for_consumer(consumer) ⇒ Object
26
27
28
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 26
def for_consumer consumer
where(consumer: consumer)
end
|
#for_consumer_id_and_provider_id(consumer_id, provider_id) ⇒ Object
10
11
12
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 10
def for_consumer_id_and_provider_id(consumer_id, provider_id)
where(Sequel[:pact_publications][:consumer_id] => consumer_id, Sequel[:pact_publications][:provider_id] => provider_id)
end
|
#for_consumer_name(consumer_name) ⇒ Object
18
19
20
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 18
def for_consumer_name(consumer_name)
where(consumer: PactBroker::Domain::Pacticipant.find_by_name(consumer_name))
end
|
#for_consumer_name_and_maybe_version_number(consumer_name, consumer_version_number) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 52
def for_consumer_name_and_maybe_version_number(consumer_name, consumer_version_number)
if consumer_version_number
where(consumer_version: PactBroker::Domain::Version.where_pacticipant_name_and_version_number(consumer_name, consumer_version_number))
else
where(consumer: PactBroker::Domain::Pacticipant.find_by_name(consumer_name))
end
end
|
#for_consumer_version_tag(tag_name) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 35
def for_consumer_version_tag tag_name
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:tags][:name].as(:tag_name))
end
base_query
.join(:tags, { version_id: :consumer_version_id, Sequel[:tags][:name] => tag_name })
.remove_overridden_revisions_from_complete_query
end
|
#for_consumer_version_tag_all_revisions(tag_name) ⇒ Object
46
47
48
49
50
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 46
def for_consumer_version_tag_all_revisions tag_name
join(:tags, { version_id: :consumer_version_id }) do
name_like(Sequel[:tags][:name], tag_name)
end
end
|
#for_latest_consumer_versions_with_tag(tag_name) ⇒ Object
The pacts for the latest versions with the specified tag (new logic) NOT the latest pact that belongs to a version with the specified tag.
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 264
def for_latest_consumer_versions_with_tag(tag_name)
head_tags = PactBroker::Domain::Tag
.select_group(:pacticipant_id, :name)
.select_append{ max(version_order).as(:latest_version_order) }
.where(name: tag_name)
head_tags_join = {
Sequel[:pact_publications][:consumer_id] => Sequel[:head_tags][:pacticipant_id],
Sequel[:pact_publications][:consumer_version_order] => Sequel[:head_tags][:latest_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:head_tags][:name].as(:tag_name))
end
base_query
.join(head_tags, head_tags_join, { table_alias: :head_tags })
.remove_overridden_revisions_from_complete_query
end
|
#for_pact_version_id(pact_version_id) ⇒ Object
350
351
352
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 350
def for_pact_version_id(pact_version_id)
where(Sequel[:pact_publications][:pact_version_id] => pact_version_id)
end
|
#for_pact_version_sha(pact_version_sha) ⇒ Object
396
397
398
399
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 396
def for_pact_version_sha(pact_version_sha)
join_pact_versions
.where(Sequel[:pact_versions][:sha] => pact_version_sha)
end
|
#for_provider(provider) ⇒ Object
22
23
24
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 22
def for_provider provider
where(provider: provider)
end
|
#for_provider_name(provider_name) ⇒ Object
14
15
16
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 14
def for_provider_name(provider_name)
where(provider: PactBroker::Domain::Pacticipant.find_by_name(provider_name))
end
|
#in_environments ⇒ Object
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 309
def in_environments
currently_deployed_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:currently_deployed_version_ids][:version_id]
}
released_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:released_versions][:version_id],
Sequel[:released_versions][:support_ended_at] => nil
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified
end
deployed = base_query.join(:currently_deployed_version_ids, currently_deployed_join)
released = base_query.join(:released_versions, released_join)
deployed.union(released).remove_overridden_revisions_from_complete_query
end
|
#join_consumer_branch_versions ⇒ Object
365
366
367
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 365
def join_consumer_branch_versions
join(:branch_versions, { Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_versions][:version_id] })
end
|
361
362
363
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 361
def join_consumer_version_tags(table_alias = :ct)
join(:tags, { Sequel[table_alias][:version_id] => Sequel[:pact_publications][:consumer_version_id]}, { table_alias: table_alias })
end
|
369
370
371
372
373
374
375
376
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 369
def join_consumer_version_tags_with_names(consumer_version_tag_names)
join(:tags, {
Sequel[:ct][:version_id] => Sequel[:pact_publications][:consumer_version_id],
Sequel[:ct][:name] => consumer_version_tag_names
}, {
table_alias: :ct
})
end
|
#join_consumer_versions(table_alias = :cv, extra_join_criteria = {}, &block) ⇒ Object
354
355
356
357
358
359
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 354
def join_consumer_versions(table_alias = :cv, = {}, &block)
versions_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[table_alias][:id]
}.merge()
join(:versions, versions_join, { table_alias: table_alias }, &block)
end
|
#join_consumers(table_alias = :consumers, base_table = :pact_publications, extra_join_criteria = {}) ⇒ Object
385
386
387
388
389
390
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 385
def join_consumers(table_alias = :consumers, base_table = :pact_publications, = {})
consumer_join = {
Sequel[base_table][:consumer_id] => Sequel[table_alias][:id]
}.merge()
join(:pacticipants, consumer_join, { table_alias: table_alias })
end
|
#join_pact_versions ⇒ Object
392
393
394
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 392
def join_pact_versions
join(:pact_versions, { Sequel[:pact_publications][:pact_version_id] => Sequel[:pact_versions][:id] })
end
|
#join_providers(table_alias = :providers, base_table = :pact_publications, extra_join_criteria = {}) ⇒ Object
378
379
380
381
382
383
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 378
def join_providers(table_alias = :providers, base_table = :pact_publications, = {})
provider_join = {
Sequel[base_table][:provider_id] => Sequel[table_alias][:id]
}.merge()
join(:pacticipants, provider_join, { table_alias: table_alias })
end
|
#latest ⇒ Object
464
465
466
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 464
def latest
order(:consumer_version_order, :revision_number).last
end
|
Returns the latest pact for each branch, returning a pact for every branch, even if the most recent version of that branch does not have a pact. This is different from for_all_branch_heads, which will find the branch head versions, and return the pacts associated with those versions. This method should not be used for ‘pacts for verification’, because it will return a pact for branches where that integration should no longer exist.
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 67
def latest_by_consumer_branch
branch_versions_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_versions][:version_id]
}
branches_join = {
Sequel[:branch_versions][:branch_id] => Sequel[:branches][:id]
}
max_orders = join(:branch_versions, branch_versions_join)
.join(:branches, branches_join)
.select_group(Sequel[:pact_publications][:consumer_id], Sequel[:pact_publications][:provider_id], Sequel[:branches][:name].as(:branch_name))
.select_append{ max(consumer_version_order).as(latest_consumer_version_order) }
max_join = {
Sequel[:max_orders][:consumer_id] => Sequel[:pact_publications][:consumer_id],
Sequel[:max_orders][:provider_id] => Sequel[:pact_publications][:provider_id],
Sequel[:max_orders][:latest_consumer_version_order] => Sequel[:pact_publications][:consumer_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:max_orders][:branch_name].as(:branch_name))
end
base_query
.remove_overridden_revisions
.join(max_orders, max_join, { table_alias: :max_orders })
end
|
The latest pact publication for each tag This uses the old logic of “the latest pact for a version that has a tag” (which always returns a pact) rather than “the pact for the latest version with a tag”
For ‘pacts for verification’ this has been replaced by for_all_tag_heads This should only be used for the UI
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 206
def latest_by_consumer_tag
tags_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:tags][:version_id],
}
max_orders = join(:tags, tags_join)
.select_group(:consumer_id, :provider_id, Sequel[:tags][:name].as(:tag_name))
.select_append{ max(consumer_version_order).as(latest_consumer_version_order) }
max_join = {
Sequel[:max_orders][:consumer_id] => Sequel[:pact_publications][:consumer_id],
Sequel[:max_orders][:provider_id] => Sequel[:pact_publications][:provider_id],
Sequel[:max_orders][:latest_consumer_version_order] => Sequel[:pact_publications][:consumer_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:max_orders][:tag_name])
end
base_query
.join(max_orders, max_join, { table_alias: :max_orders })
.remove_overridden_revisions_from_complete_query
end
|
#latest_by_consumer_version_order ⇒ Object
448
449
450
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 448
def latest_by_consumer_version_order
reverse_order(:consumer_version_order).limit(1)
end
|
#latest_for_consumer_branch(branch_name) ⇒ Object
The pact that belongs to the branch head. May return nil if the branch head does not have a pact published for it.
163
164
165
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 163
def latest_for_consumer_branch(branch_name)
for_branch_heads(branch_name)
end
|
This uses the old logic of “the latest pact for a version that has a tag” (which always returns a pact) rather than “the pact for the latest version with a tag” Need to see about updating this.
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 235
def latest_for_consumer_tag(tag_name)
tags_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:tags][:version_id],
Sequel[:tags][:name] => tag_name
}
max_orders = join(:tags, tags_join)
.select_group(:consumer_id, :provider_id, Sequel[:tags][:name].as(:tag_name))
.select_append{ max(consumer_version_order).as(latest_consumer_version_order) }
max_join = {
Sequel[:max_orders][:consumer_id] => Sequel[:pact_publications][:consumer_id],
Sequel[:max_orders][:provider_id] => Sequel[:pact_publications][:provider_id],
Sequel[:max_orders][:latest_consumer_version_order] => Sequel[:pact_publications][:consumer_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:max_orders][:tag_name])
end
base_query
.join(max_orders, max_join, { table_alias: :max_orders })
.remove_overridden_revisions_from_complete_query
end
|
#old_latest_for_consumer_branch(branch_name) ⇒ Object
The latest pact that belongs to a version on the specified branch (might not be the version that is the branch head) Always returns a pact, if any pacts exist for this branch.
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 169
def old_latest_for_consumer_branch(branch_name)
branch_versions_join = {
Sequel[:pact_publications][:consumer_version_id] => Sequel[:branch_versions][:version_id]
}
branches_join = {
Sequel[:branch_versions][:branch_id] => Sequel[:branches][:id],
Sequel[:branches][:name] => branch_name
}
max_orders = join(:branch_versions, branch_versions_join)
.join(:branches, branches_join)
.select_group(Sequel[:pact_publications][:consumer_id], Sequel[:pact_publications][:provider_id], Sequel[:branches][:name].as(:branch_name))
.select_append{ max(consumer_version_order).as(latest_consumer_version_order) }
max_join = {
Sequel[:max_orders][:consumer_id] => Sequel[:pact_publications][:consumer_id],
Sequel[:max_orders][:provider_id] => Sequel[:pact_publications][:provider_id],
Sequel[:max_orders][:latest_consumer_version_order] => Sequel[:pact_publications][:consumer_version_order]
}
base_query = self
if no_columns_selected?
base_query = base_query.select_all_qualified.select_append(Sequel[:max_orders][:branch_name].as(:branch_name))
end
base_query
.join(max_orders, max_join, { table_alias: :max_orders })
.remove_overridden_revisions_from_complete_query
end
|
#order_by_consumer_name ⇒ Object
452
453
454
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 452
def order_by_consumer_name
order_append_ignore_case(Sequel[:consumers][:name])
end
|
#order_by_consumer_version_order ⇒ Object
456
457
458
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 456
def order_by_consumer_version_order
order_append(:consumer_version_order, :revision_number)
end
|
#overall_latest ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 97
def overall_latest
self_join = {
Sequel[:pact_publications][:consumer_id] => Sequel[:pp2][:consumer_id],
Sequel[:pact_publications][:provider_id] => Sequel[:pp2][:provider_id],
Sequel[:pact_publications][:consumer_version_order] => Sequel[:pp2][:max_consumer_version_order]
}
base_query = self
base_query = base_query.select_all_qualified if no_columns_selected?
base_query.join(
base_query.select_group(:consumer_id, :provider_id).select_append{ max(:consumer_version_order).as(:max_consumer_version_order) },
self_join,
table_alias: :pp2
)
.remove_overridden_revisions_from_complete_query
end
|
#overall_latest_for_consumer_id_and_provider_id(consumer_id, provider_id) ⇒ Object
115
116
117
118
119
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 115
def overall_latest_for_consumer_id_and_provider_id(consumer_id, provider_id)
for_consumer_id_and_provider_id(consumer_id, provider_id)
.order(Sequel.desc(Sequel[:pact_publications][:consumer_version_order]), Sequel.desc(:revision_number))
.limit(1)
end
|
#provider_name_like(name) ⇒ Object
424
425
426
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 424
def provider_name_like(name)
where(name_like(Sequel[:providers][:name], name))
end
|
#remove_overridden_revisions(pact_publications_alias = :pact_publications) ⇒ Object
338
339
340
341
342
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 338
def remove_overridden_revisions(pact_publications_alias = :pact_publications)
base = self
base = base.select_all_qualified if no_columns_selected?
base.join(:latest_pact_publication_ids_for_consumer_versions, { Sequel[:lp][:pact_publication_id] => Sequel[pact_publications_alias][:id] }, { table_alias: :lp})
end
|
#remove_overridden_revisions_from_complete_query ⇒ Object
344
345
346
347
348
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 344
def remove_overridden_revisions_from_complete_query
from_self(alias: :pact_publications)
.select(Sequel[:pact_publications].*)
.remove_overridden_revisions(:pact_publications)
end
|
#tag(tag_name) ⇒ Object
405
406
407
408
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 405
def tag tag_name
filter = name_like(Sequel.qualify(:tags, :name), tag_name)
join(:tags, {version_id: :consumer_version_id}).where(filter)
end
|
#untagged ⇒ Object
30
31
32
33
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 30
def untagged
left_outer_join(:tags, { version_id: :consumer_version_id })
.where(Sequel.qualify(:tags, :name) => nil)
end
|
#verified_before_date(date) ⇒ Object
330
331
332
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 330
def verified_before_date(date)
where { Sequel[:verifications][:execution_date] < date }
end
|
#where_consumer_if_set(consumer) ⇒ Object
468
469
470
471
472
473
474
|
# File 'lib/pact_broker/pacts/pact_publication_dataset_module.rb', line 468
def where_consumer_if_set(consumer)
if consumer
where(consumer: consumer)
else
self
end
end
|