Class: MergeRequestsFinder

Inherits:
IssuableFinder show all
Includes:
MergedAtFilter
Defined in:
app/finders/merge_requests_finder.rb,
app/finders/merge_requests_finder/params.rb

Overview

Finders::MergeRequest class

Used to filter MergeRequests collections by set of params

Arguments:

current_user - which user use
params:
  scope: 'created_by_me' or 'assigned_to_me' or 'all'
  state: 'open', 'closed', 'merged', 'locked', or 'all'
  group_id: integer
  project_id: integer
  milestone_title: string
  release_tag: string
  author_id: integer
  author_username: string
  assignee_id: integer
  search: string
  in: 'title', 'description', or a string joining them with comma
  label_name: string
  sort: string
  non_archived: boolean
  my_reaction_emoji: string
  source_branch: string
  target_branch: string
  created_after: datetime
  created_before: datetime
  updated_after: datetime
  updated_before: datetime

Defined Under Namespace

Classes: Params

Constant Summary

Constants inherited from IssuableFinder

IssuableFinder::NEGATABLE_PARAMS_HELPER_KEYS

Instance Attribute Summary

Attributes inherited from IssuableFinder

#current_user, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IssuableFinder

#count_by_state, #execute, #initialize, negatable_array_params, negatable_params, negatable_scalar_params, #parent_param, #parent_param=, #row_count, #search, #should_filter_negated_args?, #use_cte_for_search?, valid_params

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from CreatedAtFilter

#by_created_at

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

This class inherits a constructor from IssuableFinder

Class Method Details

.array_paramsObject


51
52
53
# File 'app/finders/merge_requests_finder.rb', line 51

def self.array_params
  @array_params ||= super.merge(approved_by_usernames: [])
end

.scalar_paramsObject


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/finders/merge_requests_finder.rb', line 35

def self.scalar_params
  @scalar_params ||= super + [
    :approved_by_ids,
    :deployed_after,
    :deployed_before,
    :draft,
    :environment,
    :merged_after,
    :merged_before,
    :reviewer_id,
    :reviewer_username,
    :target_branch,
    :wip
  ]
end

Instance Method Details

#filter_items(_items) ⇒ Object


63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/finders/merge_requests_finder.rb', line 63

def filter_items(_items)
  items = by_commit(super)
  items = by_source_branch(items)
  items = by_draft(items)
  items = by_target_branch(items)
  items = by_merged_at(items)
  items = by_approvals(items)
  items = by_deployments(items)
  items = by_reviewer(items)

  by_source_project_id(items)
end

#filter_negated_items(items) ⇒ Object


76
77
78
79
80
# File 'app/finders/merge_requests_finder.rb', line 76

def filter_negated_items(items)
  items = super(items)
  items = by_negated_reviewer(items)
  by_negated_target_branch(items)
end

#klassObject


55
56
57
# File 'app/finders/merge_requests_finder.rb', line 55

def klass
  MergeRequest
end

#params_classObject


59
60
61
# File 'app/finders/merge_requests_finder.rb', line 59

def params_class
  MergeRequestsFinder::Params
end