Module: TFSGraph::Behaviors::Neo4jRepository::Project
- Defined in:
- lib/tfs_graph/behaviors/neo4j_repository/project.rb
Constant Summary collapse
- ROOT_BRANCH_QUERY =
"MATCH (p:project {name: {project}})-[:branches]->(b:branch) WHERE (b.original_path = {path} OR b.root = {path})"- ACTIVITY_QUERY =
"MATCH (a:project)-[:branches]->(b:branch)-[:changesets]->(c:changeset) where a.name = {name}"
Instance Method Summary collapse
- #active ⇒ Object
- #active_branches_for_root(project, branch) ⇒ Object
- #activity(project) ⇒ Object
- #activity_by_date(project, time) ⇒ Object
- #all ⇒ Object
- #branches_for_root(project, branch) ⇒ Object
- #changesets_for_root(project, branch) ⇒ Object
- #create(args) ⇒ Object
- #find_by_name(name) ⇒ Object
- #root_branches(project) ⇒ Object
Instance Method Details
#active ⇒ Object
19 20 21 22 |
# 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) ⇒ Object
46 47 48 49 50 51 52 |
# 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) ⇒ Object
62 63 64 65 66 67 |
# 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) ⇒ Object
69 70 71 72 73 74 |
# 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 ⇒ Object
15 16 17 |
# 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) ⇒ Object
38 39 40 41 42 43 44 |
# 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) ⇒ Object
54 55 56 57 58 59 60 |
# 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) ⇒ Object
8 9 10 11 12 13 |
# 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) ⇒ Object
24 25 26 27 28 29 |
# 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) ⇒ Object
31 32 33 34 35 36 |
# 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 |