module TFSGraph::Behaviors::Neo4jRepository::Project
Constants
- ACTIVITY_QUERY
- ROOT_BRANCH_QUERY
Public Instance Methods
active()
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 19 def active projects = session.query "MATCH (p:project {hidden: 'false'}) RETURN p as `project`, ID(p) as `neo_id`" rebuild_for_type self, projects, :project end
active_branches_for_root(project, branch)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 46 def active_branches_for_root(project, branch) branches = session.query "#{ROOT_BRANCH_QUERY} AND b.archived = 'false' AND b.hidden = 'false' RETURN b as `branch`, ID(b) as `neo_id`", project: project.name, path: branch.path rebuild_for_type RepositoryRegistry.branch_repository, branches, :branch end
activity(project)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 62 def activity(project) changesets = session.query "#{ACTIVITY_QUERY} RETURN c as `changeset`, ID(b) as `neo_id`", name: project.name rebuild_for_type RepositoryRegistry.changeset_repository, changesets, :changeset end
activity_by_date(project, time)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 69 def activity_by_date(project, time) changesets = session.query "#{ACTIVITY_QUERY} AND c.created >= {time} RETURN c as `changeset`, ID(b) as `neo_id`", { name: project.name, time: time.utc.to_i } rebuild_for_type RepositoryRegistry.changeset_repository, changesets, :changeset end
all()
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 15 def all get_nodes(root, :outgoing, :projects, TFSGraph::Project) end
branches_for_root(project, branch)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 38 def branches_for_root(project, branch) branches = session.query "#{ROOT_BRANCH_QUERY} RETURN b as `branch`, ID(b) as `neo_id`", project: project.name, path: branch.path rebuild_for_type RepositoryRegistry.branch_repository, branches, :branch end
changesets_for_root(project, branch)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 54 def changesets_for_root(project, branch) changesets = session.query "#{ROOT_BRANCH_QUERY} MATCH b-[:changesets]->(c:changeset) RETURN c AS `changeset`, ID(b) as `neo_id` ORDER BY c.id", project: project.name, path: branch.path rebuild_for_type RepositoryRegistry.changeset_repository, changesets, :changeset end
create(args)
click to toggle source
Calls superclass method
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 8 def create(args) obj = super relate :projects, root, obj.db_object obj end
find_by_name(name)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 24 def find_by_name(name) project = Neo4j::Label.query(:project, conditions: {name: name}).first raise TFSGraph::Repository::NotFound, "No project found for #{name}" if project.nil? rebuild project end
root_branches(project)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 31 def root_branches(project) roots = session.query "MATCH (p:project {name: {project}})-[:branches]->(b:branch {hidden: 'false', archived: 'false'}) where not has(b.root) RETURN b AS `branch`, ID(b) AS `neo_id`", project: project.name rebuild_for_type RepositoryRegistry.branch_repository, roots, :branch end
Private Instance Methods
fetch_existing_record(obj)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 83 def fetch_existing_record(obj) find_by_name(obj.name).db_object end
rebuild_for_type(repo, data, key)
click to toggle source
# File lib/tfs_graph/behaviors/neo4j_repository/project.rb, line 77 def rebuild_for_type(repo, data, key) data.each_slice(2).map do |data,id| repo.rebuild_from_query data[key]['data'], id[:neo_id] end end