Add self.project_foreign_key on both Issue and MergeRequest

parent 2ed51e7e
...@@ -145,16 +145,10 @@ module Issuable ...@@ -145,16 +145,10 @@ module Issuable
end end
def order_labels_priority(excluded_labels: []) def order_labels_priority(excluded_labels: [])
project_column =
case table_name
when Issue.table_name then "#{table_name}.project_id"
when MergeRequest.table_name then "#{table_name}.target_project_id"
end
params = { params = {
target_type: name, target_type: name,
target_column: "#{table_name}.id", target_column: "#{table_name}.id",
project_column: project_column, project_column: "#{table_name}.#{project_foreign_key}",
excluded_labels: excluded_labels excluded_labels: excluded_labels
} }
......
...@@ -138,6 +138,10 @@ class Issue < ActiveRecord::Base ...@@ -138,6 +138,10 @@ class Issue < ActiveRecord::Base
reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE
end end
def self.project_foreign_key
'project_id'
end
def self.sort(method, excluded_labels: []) def self.sort(method, excluded_labels: [])
case method.to_s case method.to_s
when 'due_date_asc' then order_due_date_asc when 'due_date_asc' then order_due_date_asc
......
...@@ -137,6 +137,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -137,6 +137,10 @@ class MergeRequest < ActiveRecord::Base
reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE
end end
def self.project_foreign_key
'target_project_id'
end
# Returns all the merge requests from an ActiveRecord:Relation. # Returns all the merge requests from an ActiveRecord:Relation.
# #
# This method uses a UNION as it usually operates on the result of # This method uses a UNION as it usually operates on the result of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment