From cd3841d132c2cdb64330f81b38b4b138f9f61010 Mon Sep 17 00:00:00 2001 From: yystopf Date: Sat, 11 Oct 2025 15:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9Aissue=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/pm/issue_links_controller.rb | 4 ++-- app/models/issue.rb | 14 ++++++++++++++ .../api/v1/issues/_simple_detail.json.jbuilder | 3 ++- .../v1/projects/explore_code/code.json.jbuilder | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/pm/issue_links_controller.rb b/app/controllers/api/pm/issue_links_controller.rb index abd43fe5f..ba75db140 100644 --- a/app/controllers/api/pm/issue_links_controller.rb +++ b/app/controllers/api/pm/issue_links_controller.rb @@ -4,8 +4,8 @@ class Api::Pm::IssueLinksController < Api::Pm::BaseController def index @links = PmLink.where(be_linkable_id: @issue.id,be_linkable_type: 'Issue').or(PmLink.where(linkable_id: @issue.id,linkable_type: 'Issue')) if params[:pm_issue_type].present? - links_1 = @links.select {|s| s.linkable.pm_issue_type == params[:pm_issue_type].to_i}.map{|i|i.id} - links_2 = @links.select {|s| s.be_linkable.pm_issue_type == params[:pm_issue_type].to_i}.map{|i|i.id} + links_1 = @links.select {|s| s.linkable_id == @issue.id && s.linkable.pm_issue_type == params[:pm_issue_type].to_i}.map{|i|i.id} + links_2 = @links.select {|s| s.be_linkable_id == @issue.id && s.be_linkable.pm_issue_type == params[:pm_issue_type].to_i}.map{|i|i.id} @links = PmLink.where(id: links_1).or(PmLink.where(id: links_2)) end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 7e8ed60fa..9e4b8ac27 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -400,4 +400,18 @@ class Issue < ApplicationRecord issues end + def depth + calculate_depth + end + + def calculate_depth(node = self, current_depth = 0) + return current_depth if node.root? || node.parent_issue.nil? + + calculate_depth(node.parent_issue, current_depth+1) + end + + def root? + root_id.nil? || root_id == id + end + end diff --git a/app/views/api/v1/issues/_simple_detail.json.jbuilder b/app/views/api/v1/issues/_simple_detail.json.jbuilder index e15876122..74e36e302 100644 --- a/app/views/api/v1/issues/_simple_detail.json.jbuilder +++ b/app/views/api/v1/issues/_simple_detail.json.jbuilder @@ -52,4 +52,5 @@ if issue.pm_issue_type.to_i == 1 && issue.requirement_issue_ext.present? json.need_type issue.requirement_issue_ext.need_type json.function_type issue.requirement_issue_ext.function_type json.identifier issue.requirement_issue_ext.identifier -end \ No newline at end of file +end +json.current_depth issue.depth \ No newline at end of file diff --git a/app/views/api/v1/projects/explore_code/code.json.jbuilder b/app/views/api/v1/projects/explore_code/code.json.jbuilder index e8e89b677..3bf8c3e72 100644 --- a/app/views/api/v1/projects/explore_code/code.json.jbuilder +++ b/app/views/api/v1/projects/explore_code/code.json.jbuilder @@ -10,7 +10,7 @@ json.results @result[:data]["SearchResults"] do |repo| end json.filename repo["Filename"] json.language repo["Language"] - json.sha repo["Co mmitID"] + json.sha repo["CommitID"] json.updated_unix repo["UpdatedUnix"] json.line_numbers repo["LineNumbers"] json.formatted_lines repo["FormattedLines"]