Class: WorkItems::SavedViews::FilterNormalizerService

Inherits:
FilterBaseService show all
Includes:
API::Concerns::Milestones::GroupProjectParams
Defined in:
app/services/work_items/saved_views/filter_normalizer_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary collapse

Attributes inherited from FilterBaseService

#container, #current_user, #filters

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from FilterBaseService

static_filters, static_negated_filters

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(filter_data:, container:, current_user:) ⇒ FilterNormalizerService

Returns a new instance of FilterNormalizerService.



10
11
12
13
14
15
# File 'app/services/work_items/saved_views/filter_normalizer_service.rb', line 10

def initialize(filter_data:, container:, current_user:)
  @filters = filter_data.to_h
  @container = container
  @current_user = current_user
  @normalized_filters = {}
end

Instance Attribute Details

#normalized_filtersObject (readonly)

Returns the value of attribute normalized_filters.



8
9
10
# File 'app/services/work_items/saved_views/filter_normalizer_service.rb', line 8

def normalized_filters
  @normalized_filters
end

Instance Method Details

#executeObject

Overridden in EE



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/work_items/saved_views/filter_normalizer_service.rb', line 18

def execute
  normalize_static_filters

  normalize_usernames(:assignee_usernames, :assignee_ids)
  normalize_author_username
  normalize_label_names
  normalize_attribute(:milestone_title, :milestone_ids, method: :find_milestone_ids)
  normalize_attribute(:release_tag, :release_ids, method: :find_release_ids,
    condition: -> { container.is_a?(Project) })

  normalize_simple_id(:crm_contact_id)
  normalize_simple_id(:crm_organization_id)
  normalize_full_path

  normalize_hierarchy

  ServiceResponse.success(payload: normalized_filters)
rescue ArgumentError => e
  ServiceResponse.error(message: e.message)
end