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<Integer,Integer>

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

Returns:

  • (Hash<Integer,Integer>)

    Mapping of status id to count ex) { 0: 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
# 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_status(collection)
  collection = by_search(collection)
  collection = by_iid(collection)
  sort(collection)
end