|
|
|
@@ -1,7 +1,7 @@ |
|
|
|
class Api::V1::Issues::ListService < ApplicationService |
|
|
|
include ActiveModel::Model |
|
|
|
|
|
|
|
attr_reader :project, :category, :participant_category, :keyword, :author_id, :issue_tag_ids |
|
|
|
attr_reader :project, :only_name, :category, :participant_category, :keyword, :author_id, :issue_tag_ids |
|
|
|
attr_reader :milestone_id, :assigner_id, :status_id, :sort_by, :sort_direction, :current_user |
|
|
|
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count |
|
|
|
|
|
|
|
@@ -13,6 +13,7 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
|
|
|
|
def initialize(project, params, current_user=nil) |
|
|
|
@project = project |
|
|
|
@only_name = params[:only_name] |
|
|
|
@category = params[:category] || 'all' |
|
|
|
@participant_category = params[:participant_category] || 'all' |
|
|
|
@keyword = params[:keyword] |
|
|
|
@@ -81,9 +82,13 @@ class Api::V1::Issues::ListService < ApplicationService |
|
|
|
issues = issues.opened |
|
|
|
end |
|
|
|
|
|
|
|
scope = issues.includes(:priority, :issue_status, :user, :show_assigners, :show_issue_tags, :version, :comment_journals) |
|
|
|
|
|
|
|
scope = scope.reorder("#{sort_by} #{sort_direction}").distinct |
|
|
|
if only_name.present? |
|
|
|
scope = issues.select(:id, :subject, :project_issues_index) |
|
|
|
scope = scope.reorder("project_issues_index asc").distinct |
|
|
|
else |
|
|
|
scope = issues.includes(:priority, :issue_status, :user, :show_assigners, :show_issue_tags, :version, :comment_journals) |
|
|
|
scope = scope.reorder("#{sort_by} #{sort_direction}").distinct |
|
|
|
end |
|
|
|
|
|
|
|
@queried_issues = scope |
|
|
|
end |
|
|
|
|