software_version_check.rb 720 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class Admin::SystemCheck::SoftwareVersionCheck < Admin::SystemCheck::BaseCheck
  3. include RoutingHelper
  4. def skip?
  5. !current_user.can?(:view_devops) || !SoftwareUpdate.check_enabled?
  6. end
  7. def pass?
  8. software_updates.empty?
  9. end
  10. def message
  11. if software_updates.any?(&:urgent?)
  12. Admin::SystemCheck::Message.new(:software_version_critical_check, nil, admin_software_updates_path, true)
  13. else
  14. Admin::SystemCheck::Message.new(:software_version_patch_check, nil, admin_software_updates_path)
  15. end
  16. end
  17. private
  18. def software_updates
  19. @software_updates ||= SoftwareUpdate.pending_to_a.filter { |update| update.urgent? || update.patch_type? }
  20. end
  21. end