Add self.project_foreign_key on both Issue and MergeRequest

This commit is contained in:
Douglas Barbosa Alexandre 2016-10-19 11:49:07 -02:00
parent 2ed51e7e25
commit fc2c64fcdf
3 changed files with 9 additions and 7 deletions

View file

@ -145,16 +145,10 @@ module Issuable
end
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 = {
target_type: name,
target_column: "#{table_name}.id",
project_column: project_column,
project_column: "#{table_name}.#{project_foreign_key}",
excluded_labels: excluded_labels
}

View file

@ -138,6 +138,10 @@ class Issue < ActiveRecord::Base
reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE
end
def self.project_foreign_key
'project_id'
end
def self.sort(method, excluded_labels: [])
case method.to_s
when 'due_date_asc' then order_due_date_asc

View file

@ -137,6 +137,10 @@ class MergeRequest < ActiveRecord::Base
reference.to_i > 0 && reference.to_i <= Gitlab::Database::MAX_INT_VALUE
end
def self.project_foreign_key
'target_project_id'
end
# Returns all the merge requests from an ActiveRecord:Relation.
#
# This method uses a UNION as it usually operates on the result of