debian-mirror-gitlab/app/finders/merge_requests_finder.rb

64 lines
1.4 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
# 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'
2017-08-17 22:00:37 +05:30
# state: 'open', 'closed', 'merged', or 'all'
2014-09-02 18:07:02 +05:30
# group_id: integer
# project_id: integer
2017-08-17 22:00:37 +05:30
# milestone_title: string
2017-09-10 17:25:29 +05:30
# author_id: integer
2014-09-02 18:07:02 +05:30
# assignee_id: integer
# search: string
# label_name: string
# sort: string
2017-08-17 22:00:37 +05:30
# non_archived: boolean
2018-03-17 18:26:18 +05:30
# my_reaction_emoji: string
2018-03-27 19:54:05 +05:30
# source_branch: string
# target_branch: string
# created_after: datetime
# created_before: datetime
# updated_after: datetime
# updated_before: datetime
2014-09-02 18:07:02 +05:30
#
2015-04-26 12:48:37 +05:30
class MergeRequestsFinder < IssuableFinder
2014-09-02 18:07:02 +05:30
def klass
MergeRequest
end
2016-09-29 09:46:39 +05:30
2018-03-27 19:54:05 +05:30
def filter_items(_items)
items = by_source_branch(super)
by_target_branch(items)
end
2016-09-29 09:46:39 +05:30
private
2018-03-27 19:54:05 +05:30
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
2017-08-17 22:00:37 +05:30
def item_project_ids(items)
items&.reorder(nil)&.select(:target_project_id)
2016-09-29 09:46:39 +05:30
end
2014-09-02 18:07:02 +05:30
end