Skip to content
Snippets Groups Projects
Verified Commit e43f95f0 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Improve the humanized action output slightly

parent 2850d4d9
No related branches found
No related tags found
No related merge requests found
......@@ -13,20 +13,33 @@ module Actions
def humanized_output
return unless output[:results]
changes = output[:results]
.select { |r| (r[:imported] || r[:exported] ) && r[:changed] }
exceptions = output[:results]
.reject { |r| r[:exception].nil? }
.group_by { |r| [r[:type], r[:additional_errors] || r[:exception]] }
.map do |k, v|
"#{v.size} templates#{k.first.nil? ? '' : " of type #{k.first}"} skipped: #{k.last}"
"#{v.size} templates#{k.first.nil? ? '' : " of type #{k.first}"} skipped because: #{k.last}"
end
out = "#{humanized_action} finished, #{output[:results].select { |r| r[:exception].nil? }.count} templates handled"
if exceptions.empty?
out += '.'
else
out += ", #{output[:results].reject { |r| r[:exception].nil? }.count} skipped;"
out += "\n\n" + exceptions.join("\n")
out = "#{humanized_action} finished, "
out += if changes.any?
"#{changes.count} templates changed"
else
'no changes to affected templates'
end
out += if exceptions.any?
", #{output[:results].reject { |r| r[:exception].nil? }.count} templates skipped;\n- " + exceptions.join("\n- ")
else
'.'
end
if changes.any?
out += "\n\nTemplates changed:\n- " + changes.map { |ch| "#{ch[:type].camel_case} | #{ch[:name]}" }.join("\n- ")
end
out
end
......@@ -41,8 +54,9 @@ module Actions
type: r[:type],
changed: r[:changed],
imported: r[:imported],
exported: r[:exported],
error: r[:additional_errors] || r[:exception]
}
}.compact
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment