app/models/katello/task_status.rb in katello-4.13.1 vs app/models/katello/task_status.rb in katello-4.14.0.rc1
- old
+ new
@@ -152,22 +152,20 @@
case details[:type]
when :package
p = self.parameters[:packages]
first_package = p.first.is_a?(Hash) ? p.first[:name] : p.first
- unless p && p.length > 0
- if self.task_type == "package_update"
- case self.overall_status
- when "running"
- return "updating"
- when "waiting"
- return "updating"
- when "error"
- return _("all packages update failed")
- else
- return _("all packages update")
- end
+ if !p && p.length > 0 && (self.task_type == "package_update")
+ case self.overall_status
+ when "running"
+ return "updating"
+ when "waiting"
+ return "updating"
+ when "error"
+ return _("all packages update failed")
+ else
+ return _("all packages update")
end
end
msg = details[:event_messages][self.overall_status]
return n_(msg[1], msg[2], p.length) % { package: first_package, total: p.length - 1 }
@@ -227,33 +225,35 @@
def generate_description
ret = []
task_type = self.task_type.to_s
- if task_type =~ /^package_group/
+ case task_type
+ when /^package_group/
action = task_type.include?("remove") ? :removed : :installed
ret = packages_change_description(result[:details][:package_group], action)
- elsif task_type == "package_install" || task_type == "errata_install"
+ when "package_install", "errata_install"
ret = packages_change_description(result[:details][:rpm], :installed)
- elsif task_type == "package_update"
+ when "package_update"
ret = packages_change_description(result[:details][:rpm], :updated)
- elsif task_type == "package_remove"
+ when "package_remove"
ret = packages_change_description(result[:details][:rpm], :removed)
end
ret
end
def rmi_error_description
errors, stacktrace = self.result[:errors]
return "" unless errors
# Handle not very friendly Pulp message
- if errors =~ /^\(.*\)$/
+ case errors
+ when /^\(.*\)$/
if stacktrace.class == Array
stacktrace.last.split(":").first
else
stacktrace.split("(").first
end
- elsif errors =~ /^\[.*,.*\]$/m
+ when /^\[.*,.*\]$/m
result = errors.split(",").map do |error|
error.gsub(/^\W+|\W+$/, "")
end
result.join("\n")
else