Class: AlertManagement::AlertsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/alert_management/alerts_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, project, params) ⇒ AlertsFinder

Returns a new instance of AlertsFinder.



11
12
13
14
15
# File 'app/finders/alert_management/alerts_finder.rb', line 11

def initialize(current_user, project, params)
  @current_user = current_user
  @project = project
  @params = params
end

Class Method Details

.counts_by_status(current_user, project, params = {}) ⇒ Hash<Symbol,Integer>

Returns Mapping of status id to count ex) { triggered: 6, …etc }.

Returns:

  • (Hash<Symbol,Integer>)

    Mapping of status id to count ex) { triggered: 6, …etc }



7
8
9
# File 'app/finders/alert_management/alerts_finder.rb', line 7

def self.counts_by_status(current_user, project, params = {})
  new(current_user, project, params).execute.counts_by_status
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/finders/alert_management/alerts_finder.rb', line 17

def execute
  return AlertManagement::Alert.none unless authorized?

  collection = project.alert_management_alerts
  collection = by_domain(collection)
  collection = by_status(collection)
  collection = by_iid(collection)
  collection = by_assignee(collection)
  collection = by_search(collection)

  sort(collection)
end