Filter projects on dashboard

This commit is contained in:
Dmitriy Zaporozhets 2012-11-30 06:14:05 +03:00
parent a03f318964
commit c38b9a2f80
5 changed files with 46 additions and 0 deletions

View file

@ -74,6 +74,8 @@ class Project < ActiveRecord::Base
scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) }
scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
class << self
def authorized_for user