Fix group duplication on dashboard and project order in group
This commit is contained in:
parent
ff9a2e2a93
commit
1d889a79fb
4 changed files with 15 additions and 7 deletions
|
@ -73,7 +73,7 @@ class Project < ActiveRecord::Base
|
|||
scope :public_only, where(private_flag: false)
|
||||
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 :authorized_for, ->(user) { joins(:users_projects) { where(user_id: user.id) } }
|
||||
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
|
||||
|
||||
class << self
|
||||
def active
|
||||
|
@ -285,4 +285,9 @@ class Project < ActiveRecord::Base
|
|||
merge_requests
|
||||
end
|
||||
end
|
||||
|
||||
def self.authorized_for user
|
||||
projects = includes(:users_projects, :namespace)
|
||||
projects = projects.where("users_projects.user_id = :user_id or projects.owner_id = :user_id or namespaces.owner_id = :user_id", user_id: user.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,7 +127,8 @@ class User < ActiveRecord::Base
|
|||
def accessed_groups
|
||||
@accessed_groups ||= begin
|
||||
groups = Group.where(id: self.projects.pluck(:namespace_id)).all
|
||||
groups + self.groups
|
||||
groups = groups + self.groups
|
||||
groups.uniq
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue