diff --git a/app/controllers/api/pm/issues_controller.rb b/app/controllers/api/pm/issues_controller.rb index d7890e15a..f6dfd39b3 100644 --- a/app/controllers/api/pm/issues_controller.rb +++ b/app/controllers/api/pm/issues_controller.rb @@ -144,7 +144,8 @@ class Api::Pm::IssuesController < Api::Pm::BaseController end end p.workbook.add_worksheet(:name => 'link_relations') do |sheet| - links = PmLink.joins(:linkable_issue).where(issues: {pm_project_id: params[:pm_project_id]}) + # links = PmLink.joins(:linkable_issue).where(issues: {pm_project_id: params[:pm_project_id]}) + links = PmLink.find_by_sql("SELECT `pm_links`.* FROM `pm_links` INNER JOIN `issues` ON `issues`.`id` = `pm_links`.`linkable_id` AND `pm_links`.`linkable_type` = 'Issue' WHERE `issues`.`pm_project_id` = #{params[pm_project_id]}") sheet.add_row ["ID", "被关联工作项ID"] links.each do |link| sheet.add_row [link.linkable_id, link.be_linkable_id] diff --git a/app/models/pm_link.rb b/app/models/pm_link.rb index e45578158..d9d9a7893 100644 --- a/app/models/pm_link.rb +++ b/app/models/pm_link.rb @@ -19,8 +19,8 @@ class PmLink < ApplicationRecord belongs_to :linkable, polymorphic: true belongs_to :be_linkable, polymorphic: true - belongs_to :linkable_issue, -> {where(pm_links: {linkable_type: 'Issue'})}, foreign_key: 'linkable_id', class_name: 'Issue' - belongs_to :be_linkable_issue, -> {where(pm_links: {be_linkable_type: 'Issue'})}, foreign_key: 'be_linkable_id', class_name: 'Issue' + # belongs_to :linkable_issue, -> {where(pm_links: {linkable_type: 'Issue'})}, foreign_key: 'linkable_id', class_name: 'Issue' + # belongs_to :be_linkable_issue, -> {where(pm_links: {be_linkable_type: 'Issue'})}, foreign_key: 'be_linkable_id', class_name: 'Issue' def be_linkable be_linkable_type.constantize.find be_linkable_id