SQL Fixes
This commit is contained in:
parent
8b76e30656
commit
ce1b79afa9
|
@ -50,7 +50,7 @@ class GroupsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def people
|
def people
|
||||||
@users = group.projects.map(&:users).flatten.uniq
|
@users = group.users
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -23,10 +23,14 @@ class Group < ActiveRecord::Base
|
||||||
delegate :name, to: :owner, allow_nil: true, prefix: true
|
delegate :name, to: :owner, allow_nil: true, prefix: true
|
||||||
|
|
||||||
def self.search query
|
def self.search query
|
||||||
where("name like :query or code like :query", query: "%#{query}%")
|
where("name like :query OR code like :query", query: "%#{query}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
code
|
code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def users
|
||||||
|
User.joins(:users_projects).where('users_projects.project_id' => project_ids).uniq
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,15 +30,15 @@ class Project < ActiveRecord::Base
|
||||||
|
|
||||||
# Scopes
|
# Scopes
|
||||||
scope :public_only, where(private_flag: false)
|
scope :public_only, where(private_flag: false)
|
||||||
scope :without_user, ->(user) { where("id not in (:ids)", ids: user.projects.map(&:id) ) }
|
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 :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) }
|
||||||
|
|
||||||
def self.active
|
def self.active
|
||||||
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
|
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search query
|
def self.search query
|
||||||
where("name like :query or code like :query or path like :query", query: "%#{query}%")
|
where("name like :query OR code like :query OR path like :query", query: "%#{query}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_by_user(params, user)
|
def self.create_by_user(params, user)
|
||||||
|
|
Loading…
Reference in a new issue