diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index 84f4dd722..6f615e498 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -9,8 +9,11 @@ class Api::V1::IssuesController < Api::V1::BaseController @total_issues_count = @object_result[:total_issues_count] @opened_issues_count = @object_result[:opened_issues_count] @closed_issues_count = @object_result[:closed_issues_count] - - @issues = kaminari_paginate(@object_result[:data]) + if params[:only_name].present? + @issues = kaminary_select_paginate(@object_result[:data].pluck(:id, :subject)) + else + @issues = kaminari_paginate(@object_result[:data]) + end end def create diff --git a/app/models/message_template/issue_changed.rb b/app/models/message_template/issue_changed.rb index f5e8c7628..5ac3a120f 100644 --- a/app/models/message_template/issue_changed.rb +++ b/app/models/message_template/issue_changed.rb @@ -31,16 +31,16 @@ class MessageTemplate::IssueChanged < MessageTemplate change_count = change_params.keys.size # 疑修负责人修改 if change_params[:assigned_to_id].present? - assigner1 = User.find_by_id(change_params[:assigned_to_id][0]) - assigner2 = User.find_by_id(change_params[:assigned_to_id][1]) + assigner1 = User.where(id: change_params[:assigned_to_id][0]) + assigner2 = User.where(id: change_params[:assigned_to_id][1]) if change_count > 1 content.sub!('{ifassigner}', '
') else content.sub!('{ifassigner}', '') end content.sub!('{endassigner}', '') - content.gsub!('{assigner1}', assigner1.present? ? assigner1&.real_name : '未指派成员') - content.gsub!('{assigner2}', assigner2.present? ? assigner2&.real_name : '未指派成员') + content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '未指派成员') + content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '未指派成员') else content.gsub!(/({ifassigner})(.*)({endassigner})/, '') end @@ -217,8 +217,8 @@ class MessageTemplate::IssueChanged < MessageTemplate content.sub!('{ifassigner}', '') end content.sub!('{endassigner}', '') - content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '无') - content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '无') + content.gsub!('{assigner1}', assigner1.present? ? assigner1.map{|a| a&.real_name}.join("、") : '未指派成员') + content.gsub!('{assigner2}', assigner2.present? ? assigner2.map{|a| a&.real_name}.join("、") : '未指派成员') else content.gsub!(/({ifassigner})(.*)({endassigner})/, '') end diff --git a/app/views/api/v1/issues/index.json.jbuilder b/app/views/api/v1/issues/index.json.jbuilder index 6a04c56ac..ddc36ffb7 100644 --- a/app/views/api/v1/issues/index.json.jbuilder +++ b/app/views/api/v1/issues/index.json.jbuilder @@ -4,5 +4,9 @@ json.closed_count @closed_issues_count json.total_count @issues.total_count json.has_created_issues @project.issues.size > 0 json.issues @issues.each do |issue| - json.partial! "simple_detail", locals: {issue: issue} + if params[:only_name].present? + json.partial! "simple_detail", locals: {issue: issue} + else + json.(issue, :id, :subject) + end end \ No newline at end of file