scope:order_milestone_due_asc,->{left_joins_milestones.reorder(Arel.sql('milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date ASC'))}
scope:without_release,->do
left_joins_milestones
.joins("LEFT OUTER JOIN milestone_releases ON milestones.id = milestone_releases.milestone_id")
joins("LEFT OUTER JOIN milestone_releases ON #{table_name}.milestone_id = milestone_releases.milestone_id")
.where('milestone_releases.release_id IS NULL')
end
scope:left_joins_milestones_joins_releases,->do
left_joins_milestones
.joins("JOIN milestone_releases ON milestones.id = milestone_releases.milestone_id
JOIN releases ON milestone_releases.release_id = releases.id")
.where('milestone_releases.release_id IS NOT NULL').distinct
scope:joins_milestone_releases,->do
joins("JOIN milestone_releases ON issues.milestone_id = milestone_releases.milestone_id
JOIN releases ON milestone_releases.release_id = releases.id").distinct
end
scope:without_label,->{joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: {id: nil})}