This commit is contained in:
parent
43cbb9cf4f
commit
edf60ca0a8
|
@ -10,7 +10,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
|||
@opened_issues_count = @object_result[:opened_issues_count]
|
||||
@closed_issues_count = @object_result[:closed_issues_count]
|
||||
if params[:only_name].present?
|
||||
@issues = kaminary_select_paginate(@object_result[:data].select(:id, :subject, :project_issues_index))
|
||||
@issues = kaminary_select_paginate(@object_result[:data])
|
||||
else
|
||||
@issues = kaminari_paginate(@object_result[:data])
|
||||
end
|
||||
|
@ -86,6 +86,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
|||
|
||||
def query_params
|
||||
params.permit(
|
||||
:only_name,
|
||||
:category,
|
||||
:participant_category,
|
||||
:keyword, :author_id,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue