Class: GraphStarter::Group

Inherits:
Object
  • Object
show all
Includes:
Neo4j::ActiveNode
Defined in:
app/models/graph_starter/group.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_query(query_string) ⇒ Object



20
21
22
23
24
25
26
# File 'app/models/graph_starter/group.rb', line 20

def self.for_query(query_string)
  query_regex = Regexp.new('.*' + query_string.gsub(/[\s\*]+/, '.*') + '.*', 'i')

  as(:group)
    .where('group.name =~ {query}')
    .params(query: query_regex)
end

.rootsObject



16
17
18
# File 'app/models/graph_starter/group.rb', line 16

def self.roots
  all(:group).where('NOT(group<-[:HAS_SUBGROUP]-())')
end

Instance Method Details

#addable_usersObject



28
29
30
31
32
33
34
# File 'app/models/graph_starter/group.rb', line 28

def addable_users
  User.as(:user)
    .groups(:group, nil, optional: true)
    .where('group.uuid <> ?', id)
    .query.with(:user)
    .proxy_as(User, :user)
end