debian-mirror-gitlab/app/controllers/concerns/issuable_collections_action.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2019-03-02 22:35:43 +05:30
module IssuableCollectionsAction
2015-12-23 02:04:40 +05:30
extend ActiveSupport::Concern
2016-09-13 17:45:13 +05:30
include IssuableCollections
2018-11-08 19:23:39 +05:30
include IssuesCalendar
2015-12-23 02:04:40 +05:30
2023-03-17 16:20:25 +05:30
included do
before_action :check_search_rate_limit!, only: [:issues, :merge_requests], if: -> {
2023-04-23 21:23:45 +05:30
params[:search].present?
2023-03-17 16:20:25 +05:30
}
end
2018-03-17 18:26:18 +05:30
# rubocop:disable Gitlab/ModuleWithInstanceVariables
2015-12-23 02:04:40 +05:30
def issues
2018-03-17 18:26:18 +05:30
@issues = issuables_collection
2016-09-13 17:45:13 +05:30
.non_archived
.page(params[:page])
2016-04-02 18:10:28 +05:30
2020-06-23 00:09:42 +05:30
@issuable_meta_data = Gitlab::IssuableMetadata.new(current_user, @issues).data
2017-08-17 22:00:37 +05:30
2015-12-23 02:04:40 +05:30
respond_to do |format|
format.html
2022-05-07 20:08:51 +05:30
format.atom { render layout: 'xml' }
2015-12-23 02:04:40 +05:30
end
end
2019-03-02 22:35:43 +05:30
def merge_requests
@merge_requests = issuables_collection.page(params[:page])
2020-06-23 00:09:42 +05:30
@issuable_meta_data = Gitlab::IssuableMetadata.new(current_user, @merge_requests).data
2023-04-23 21:23:45 +05:30
rescue ActiveRecord::QueryCanceled => exception # rubocop:disable Database/RescueQueryCanceled
log_exception(exception)
@search_timeout_occurred = true
2019-03-02 22:35:43 +05:30
end
2018-03-17 18:26:18 +05:30
# rubocop:enable Gitlab/ModuleWithInstanceVariables
2018-03-27 19:54:05 +05:30
2018-11-08 19:23:39 +05:30
def issues_calendar
render_issues_calendar(issuables_collection)
end
2018-03-27 19:54:05 +05:30
private
2019-12-04 20:38:33 +05:30
def sorting_field
2019-03-02 22:35:43 +05:30
case action_name
when 'issues'
Issue::SORTING_PREFERENCE_FIELD
when 'merge_requests'
MergeRequest::SORTING_PREFERENCE_FIELD
end
end
2018-03-27 19:54:05 +05:30
def finder_type
2019-03-02 22:35:43 +05:30
case action_name
when 'issues', 'issues_calendar'
IssuesFinder
when 'merge_requests'
MergeRequestsFinder
end
end
def finder_options
2022-11-25 23:54:43 +05:30
issue_types = Issue::TYPES_FOR_LIST
2021-01-03 14:25:43 +05:30
super.merge(
non_archived: true,
2022-11-25 23:54:43 +05:30
issue_types: issue_types
2021-01-03 14:25:43 +05:30
)
2018-03-27 19:54:05 +05:30
end
2015-12-23 02:04:40 +05:30
end