Skip to content

Commit

Permalink
create table of default severities
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Nov 16, 2023
1 parent 24c204d commit 052b884
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 1 addition & 7 deletions app/helpers/problems_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
module ProblemsHelper
def problem_severity(problem)
{
missing: :danger,
empty: :info,
nesting: :warning,
inefficient: :info,
duplicate: :warning
}[problem.category.to_sym] || :silent
Problem::DEFAULT_SEVERITIES[problem.category.to_sym] || :silent
end

def max_problem_severity
Expand Down
9 changes: 9 additions & 0 deletions app/models/problem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class Problem < ApplicationRecord
:danger
]

DEFAULT_SEVERITIES = {
missing: :danger,
empty: :info,
destination_exists: :silent,
nesting: :warning,
inefficient: :info,
duplicate: :warning
}

def self.create_or_clear(problematic, cat, present, options = {})
if present
problematic.problems.create(options.merge(category: cat))
Expand Down

0 comments on commit 052b884

Please sign in to comment.