Skip to content

Commit

Permalink
fix(matrix): exceptions on matrix page due to recent query optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 25, 2019
1 parent 301b30c commit 3c504ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/matrix/quick_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def pact_created_at
end

def verification_executed_at
verification.execution_date
verification&.execution_date
end

# Add logic for ignoring case
Expand Down
58 changes: 29 additions & 29 deletions lib/pact_broker/ui/view_models/matrix_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@ def initialize line
end

def provider_name
@line[:provider_name]
@line.provider_name
end

def provider_name_url
hal_browser_url(pacticipant_url_from_params(pacticipant_name: provider_name))
end

def consumer_name
@line[:consumer_name]
@line.consumer_name
end

def consumer_name_url
hal_browser_url(pacticipant_url_from_params(pacticipant_name: consumer_name))
end

def pact_version_sha
@line[:pact_version_sha]
@line.pact_version_sha
end

# verification number, used in verification_url method
def number
@line[:verification_number]
@line.verification_number
end

def pact_revision_number
@line[:pact_revision_number]
@line.pact_revision_number
end

def consumer_name
@line[:consumer_name]
@line.consumer_name
end

def consumer_version_number
@line[:consumer_version_number]
@line.consumer_version_number
end

def display_consumer_version_number
Expand All @@ -63,23 +63,23 @@ def consumer_version_number_url
end

def consumer_version_order
@line[:consumer_version_order]
@line.consumer_version_order
end

def provider_name
@line[:provider_name]
@line.provider_name
end

def provider_version_number
@line[:provider_version_number]
@line.provider_version_number
end

def display_provider_version_number
PactBroker::Versions::AbbreviateNumber.call(provider_version_number)
end

def provider_version_order
@line[:provider_version_order]
@line.provider_version_order
end

def provider_version_number_url
Expand All @@ -88,52 +88,52 @@ def provider_version_number_url
end

def provider_version_order
if @line[:verification_executed_at]
@line[:verification_executed_at].to_time.to_i
if @line.verification_executed_at
@line.verification_executed_at.to_time.to_i
else
0
end
end

def latest_consumer_version_tags
@line[:consumer_version_tags]
.select{ | tag | tag[:latest] }
@line.consumer_version_tags
.select{ | tag | tag.latest }
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
end

def other_consumer_version_tags
@line[:consumer_version_tags]
.select{ | tag | !tag[:latest] }
@line.consumer_version_tags
.select{ | tag | !tag.latest }
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: consumer_name, version_number: consumer_version_number)) }
end

def latest_provider_version_tags
@line[:provider_version_tags]
.select{ | tag | tag[:latest] }
@line.provider_version_tags
.select{ | tag | tag.latest }
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
end

def other_provider_version_tags
@line[:provider_version_tags]
.select{ | tag | !tag[:latest] }
@line.provider_version_tags
.select{ | tag | !tag.latest }
.collect{ | tag | MatrixTag.new(tag.to_hash.merge(pacticipant_name: provider_name, version_number: provider_version_number)) }
end

def orderable_fields
[consumer_name, consumer_version_order, pact_revision_number, provider_name, @line[:verification_id]]
[consumer_name, consumer_version_order, pact_revision_number, provider_name, @line.verification_id]
end

def <=> other
(self.orderable_fields <=> other.orderable_fields) * -1
end

def pseudo_branch_verification_status
if @line[:verification_executed_at]
DateHelper.distance_of_time_in_words(@line[:verification_executed_at], DateTime.now) + " ago"
if @line.verification_executed_at
DateHelper.distance_of_time_in_words(@line.verification_executed_at, DateTime.now) + " ago"
else
''
end
# case @line[:success]
# case @line.success
# when true then "Verified"
# when false then "Failed"
# else ''
Expand All @@ -145,7 +145,7 @@ def verification_status_url
end

def pact_publication_date
relative_date(@line[:pact_created_at])
relative_date(@line.pact_created_at)
end

def pact_publication_date_url
Expand All @@ -157,11 +157,11 @@ def relative_date date
end

def pact_published_order
@line[:pact_created_at].to_time.to_i
@line.pact_created_at.to_time.to_i
end

def verification_status_class
case @line[:success]
case @line.success
when true then 'success'
when false then 'danger'
else ''
Expand All @@ -177,7 +177,7 @@ def overwritten= overwritten
end

def inherited_verification_message
if @line[:verification_executed_at] && @line[:pact_created_at] > @line[:verification_executed_at]
if @line.verification_executed_at && @line.pact_created_at > @line.verification_executed_at
"The verification date is before the pact publication date because this verification has been inherited from a previously verified pact with identical content."
end
end
Expand Down

0 comments on commit 3c504ba

Please sign in to comment.