scope:left_joins_milestones,->{joins("LEFT OUTER JOIN milestones ON #{table_name}.milestone_id = milestones.id")}
scope:left_joins_milestones,->{joins("LEFT OUTER JOIN milestones ON #{table_name}.milestone_id = milestones.id")}
scope:order_milestone_due_desc,->{left_joins_milestones.reorder('CASE WHEN milestones.due_date IS NULL then 0 ELSE 1 END DESC, CASE WHEN milestones.id IS NULL then 0 ELSE 1 END DESC, milestones.due_date DESC')}
scope:order_milestone_due_desc,->{left_joins_milestones.reorder('milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date DESC')}
scope:order_milestone_due_asc,->{left_joins_milestones.reorder('CASE WHEN milestones.due_date IS NULL then 1 ELSE 0 END ASC, CASE WHEN milestones.id IS NULL then 1 ELSE 0 END ASC, milestones.due_date ASC')}
scope:order_milestone_due_asc,->{left_joins_milestones.reorder('milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date ASC')}
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})}
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})}