Use join instead of subquery on Label.unprioritized scope
This commit is contained in:
parent
4c9241075d
commit
f99744d00d
1 changed files with 8 additions and 1 deletions
|
@ -39,7 +39,14 @@ class Label < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.unprioritized(project)
|
||||
where.not(id: prioritized(project).select(:id))
|
||||
labels = Label.arel_table
|
||||
priorities = LabelPriority.arel_table
|
||||
|
||||
label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin).
|
||||
on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id))).
|
||||
join_sources
|
||||
|
||||
joins(label_priorities).where(priorities[:priority].eq(nil))
|
||||
end
|
||||
|
||||
def self.left_join_priorities
|
||||
|
|
Loading…
Reference in a new issue