2014-02-25 12:15:08 -05:00
|
|
|
# Finders::MergeRequest class
|
|
|
|
#
|
|
|
|
# Used to filter MergeRequests collections by set of params
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# current_user - which user use
|
|
|
|
# params:
|
2018-05-13 22:07:53 -04:00
|
|
|
# scope: 'created_by_me' or 'assigned_to_me' or 'all'
|
2018-06-26 15:30:29 -04:00
|
|
|
# state: 'open', 'closed', 'merged', 'locked', or 'all'
|
2014-02-25 12:15:08 -05:00
|
|
|
# group_id: integer
|
|
|
|
# project_id: integer
|
2017-03-31 05:38:40 -04:00
|
|
|
# milestone_title: string
|
2017-07-24 16:07:37 -04:00
|
|
|
# author_id: integer
|
2014-02-25 12:15:08 -05:00
|
|
|
# assignee_id: integer
|
|
|
|
# search: string
|
|
|
|
# label_name: string
|
|
|
|
# sort: string
|
2016-11-27 05:33:15 -05:00
|
|
|
# non_archived: boolean
|
2017-09-03 21:43:14 -04:00
|
|
|
# my_reaction_emoji: string
|
2018-02-23 11:04:20 -05:00
|
|
|
# source_branch: string
|
|
|
|
# target_branch: string
|
2018-02-28 06:16:29 -05:00
|
|
|
# created_after: datetime
|
|
|
|
# created_before: datetime
|
|
|
|
# updated_after: datetime
|
|
|
|
# updated_before: datetime
|
2014-02-25 12:15:08 -05:00
|
|
|
#
|
2014-09-02 08:28:27 -04:00
|
|
|
class MergeRequestsFinder < IssuableFinder
|
2014-02-25 12:15:08 -05:00
|
|
|
def klass
|
|
|
|
MergeRequest
|
|
|
|
end
|
2017-02-07 08:15:07 -05:00
|
|
|
|
2018-02-23 11:04:20 -05:00
|
|
|
def filter_items(_items)
|
|
|
|
items = by_source_branch(super)
|
|
|
|
|
|
|
|
by_target_branch(items)
|
|
|
|
end
|
|
|
|
|
2017-02-07 08:15:07 -05:00
|
|
|
private
|
|
|
|
|
2018-02-23 11:04:20 -05:00
|
|
|
def source_branch
|
|
|
|
@source_branch ||= params[:source_branch].presence
|
|
|
|
end
|
|
|
|
|
|
|
|
def by_source_branch(items)
|
|
|
|
return items unless source_branch
|
|
|
|
|
|
|
|
items.where(source_branch: source_branch)
|
|
|
|
end
|
|
|
|
|
|
|
|
def target_branch
|
|
|
|
@target_branch ||= params[:target_branch].presence
|
|
|
|
end
|
|
|
|
|
|
|
|
def by_target_branch(items)
|
|
|
|
return items unless target_branch
|
|
|
|
|
|
|
|
items.where(target_branch: target_branch)
|
|
|
|
end
|
2014-02-25 12:15:08 -05:00
|
|
|
end
|