forked from Trustie/forgeplus
新增:issue层级字段
This commit is contained in:
parent
536e038657
commit
cd3841d132
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
end
|
||||
json.current_depth issue.depth
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue