Class: PactBroker::Matrix::QuickRow
- Inherits:
-
Object
- Object
- PactBroker::Matrix::QuickRow
- Defined in:
- lib/pact_broker/matrix/quick_row.rb
Direct Known Subclasses
Constant Summary collapse
- LV =
Tables
:latest_verification_id_for_pact_version_and_provider_version
- LP =
:latest_pact_publication_ids_for_consumer_versions
- LP_LV_JOIN =
Joins
{ Sequel[:p][:pact_version_id] => Sequel[:v][:pact_version_id] }
- CONSUMER_VERSION_JOIN =
{ Sequel[:p][:consumer_version_id] => Sequel[:cv][:id] }
- PROVIDER_VERSION_JOIN =
{ Sequel[:v][:provider_version_id] => Sequel[:pv][:id] }
- PACT_COLUMNS =
[ Sequel[:p][:consumer_id], Sequel[:p][:provider_id], Sequel[:p][:consumer_version_id], Sequel[:p][:pact_publication_id], Sequel[:p][:pact_version_id], Sequel[:p][:created_at].as(:consumer_version_created_at), Sequel[:p][:pact_publication_id].as(:pact_order) ]
- VERIFICATION_COLUMNS =
[ Sequel[:v][:provider_version_id], Sequel[:v][:verification_id], Sequel[:v][:created_at].as(:provider_version_created_at) ]
- LAST_ACTION_DATE =
Sequel.lit("CASE WHEN (provider_version_created_at IS NOT NULL AND provider_version_created_at > consumer_version_created_at) THEN provider_version_created_at ELSE consumer_version_created_at END").as(:last_action_date)
- ALL_COLUMNS =
PACT_COLUMNS + VERIFICATION_COLUMNS
- SELECT_ALL_COLUMN_ARGS =
cachable select arguments
[:select_all_columns] + ALL_COLUMNS
- SELECT_PACTICIPANT_IDS_ARGS =
[:select_pacticipant_ids, Sequel[:p][:consumer_id], Sequel[:p][:provider_id]]
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Add logic for ignoring case.
- #compare_name_asc(name1, name2) ⇒ Object
- #compare_number_desc(number1, number2) ⇒ Object
- #consumer_name ⇒ Object
- #consumer_version_number ⇒ Object
- #consumer_version_order ⇒ Object
- #eql?(obj) ⇒ Boolean
- #has_verification? ⇒ Boolean
- #involves_pacticipant_with_name?(pacticipant_name) ⇒ Boolean
- #last_action_date ⇒ Object
- #pact_created_at ⇒ Object
- #pact_revision_number ⇒ Object
- #pact_version_sha ⇒ Object
- #pacticipant_names ⇒ Object
- #provider_name ⇒ Object
- #provider_version_id ⇒ Object
- #provider_version_number ⇒ Object
- #provider_version_order ⇒ Object
-
#return_or_raise_if_not_set(key) ⇒ Object
This model needs the verifications and pacticipants joined to it before it can be used, as it’s not a “real” model.
-
#success ⇒ Object
end dataset_module.
- #to_s ⇒ Object
- #verification_executed_at ⇒ Object
- #verification_id ⇒ Object
- #verification_number ⇒ Object
Instance Method Details
#<=>(other) ⇒ Object
Add logic for ignoring case
293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 293 def <=> other comparisons = [ compare_name_asc(consumer_name, other.consumer_name), compare_number_desc(consumer_version_order, other.consumer_version_order), compare_number_desc(pact_revision_number, other.pact_revision_number), compare_name_asc(provider_name, other.provider_name), compare_number_desc(provider_version_order, other.provider_version_order), compare_number_desc(verification_id, other.verification_id) ] comparisons.find{|c| c != 0 } || 0 end |
#compare_name_asc(name1, name2) ⇒ Object
306 307 308 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 306 def compare_name_asc name1, name2 name1 <=> name2 end |
#compare_number_desc(number1, number2) ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 314 def compare_number_desc number1, number2 if number1 && number2 number2 <=> number1 elsif number1 1 else -1 end end |
#consumer_name ⇒ Object
346 347 348 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 346 def consumer_name consumer.name end |
#consumer_version_number ⇒ Object
350 351 352 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 350 def consumer_version_number consumer_version.number end |
#consumer_version_order ⇒ Object
354 355 356 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 354 def consumer_version_order consumer_version.order end |
#eql?(obj) ⇒ Boolean
324 325 326 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 324 def eql?(obj) (obj.class == model) && (obj.values == values) end |
#has_verification? ⇒ Boolean
374 375 376 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 374 def has_verification? !!verification_id end |
#involves_pacticipant_with_name?(pacticipant_name) ⇒ Boolean
332 333 334 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 332 def involves_pacticipant_with_name?(pacticipant_name) pacticipant_name.include?(pacticipant_name) end |
#last_action_date ⇒ Object
370 371 372 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 370 def last_action_date return_or_raise_if_not_set(:last_action_date) end |
#pact_created_at ⇒ Object
284 285 286 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 284 def pact_created_at pact_publication.created_at end |
#pact_revision_number ⇒ Object
272 273 274 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 272 def pact_revision_number pact_publication.revision_number end |
#pact_version_sha ⇒ Object
268 269 270 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 268 def pact_version_sha pact_version.sha end |
#pacticipant_names ⇒ Object
328 329 330 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 328 def pacticipant_names [consumer_name, provider_name] end |
#provider_name ⇒ Object
358 359 360 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 358 def provider_name provider.name end |
#provider_version_id ⇒ Object
336 337 338 339 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 336 def provider_version_id # null when not verified values[:provider_version_id] end |
#provider_version_number ⇒ Object
362 363 364 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 362 def provider_version_number provider_version&.number end |
#provider_version_order ⇒ Object
366 367 368 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 366 def provider_version_order provider_version&.order end |
#return_or_raise_if_not_set(key) ⇒ Object
This model needs the verifications and pacticipants joined to it before it can be used, as it’s not a “real” model.
380 381 382 383 384 385 386 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 380 def return_or_raise_if_not_set(key) if values.key?(key) values[key] else raise "Required table not joined" end end |
#success ⇒ Object
end dataset_module
264 265 266 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 264 def success verification&.success end |
#to_s ⇒ Object
310 311 312 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 310 def to_s "#{consumer_name} v#{consumer_version_number} #{provider_name} #{provider_version_number} #{success}" end |
#verification_executed_at ⇒ Object
288 289 290 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 288 def verification_executed_at verification&.execution_date end |
#verification_id ⇒ Object
341 342 343 344 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 341 def verification_id # null when not verified return_or_raise_if_not_set(:verification_id) end |
#verification_number ⇒ Object
276 277 278 |
# File 'lib/pact_broker/matrix/quick_row.rb', line 276 def verification_number verification&.number end |