Skip to content

Commit

Permalink
Skip empty subcategories
Browse files Browse the repository at this point in the history
Signed-off-by: Crola1702 <[email protected]>
  • Loading branch information
Crola1702 committed Jul 4, 2024
1 parent f05d3f6 commit 2d14e8c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions database/scripts/lib/report_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def self.format_datetime(datetime)
end

def self.build_regressions(br_array)
return "" if br_array.empty?
table = "| Reference Build | Failure DateTime | Failure Reason |\n| -- | -- | -- |\n"
br_array.each do |br_hash|
reference_build = "[#{br_hash['job_name']}##{br_hash['build_number']}](#{get_build_url(br_hash['job_name'], br_hash['build_number'])})"
Expand All @@ -42,15 +43,18 @@ def self.format_report(report_hash)
output_report = ""

report_hash.each_pair do |category, subcategory_hash|
output_report += "<details><summary><h1>#{category}</h1></summary>\n"
output_report += "<h1>#{category.gsub('_', ' ').capitalize}</h1>"
subcategory_hash.each_pair do |subcategory, subcategory_report| # Assume that we're traversing a hash of hashes
output_report += "<details><summary><h2>#{subcategory}</h2></summary>\n"

# Subcategory report is plain markdown
output_report += !subcategory_report.empty? ? "\n#{subcategory_report}\n" : "Emtpy!!"
output_report += "</details>\n"
next if subcategory_report.empty?

subcategory_report_title = "<h2>#{subcategory.gsub('_', ' ').capitalize}</h2>"
if category = 'urgent'
subcategory_report_str = "#{subcategory_report_title}\n#{subcategory_report}"
else
subcategory_report_str = "<details><summary>#{subcategory_report_title}</summary>\n#{subcategory_report}<details>"
end
output_report += subcategory_report_str
end
output_report += "</details>\n"
end
output_report
end
Expand Down

0 comments on commit 2d14e8c

Please sign in to comment.