def crawl(self, repository_id, pull_request_id): """ Entry point for this class """ if (repository_id is None) or (pull_request_id is None): print("could not get work item one of the id's was None") print(repository_id) print(pull_request_id) return graph = GraphBuilder().GetNewGraph() pull_request = PullRequest.select(graph, pull_request_id).first() if pull_request is None: print("Could not continue, pullrequest was not in db") return url = self.pull_request_workitems_url(repository_id, pull_request.Id) data = self.get_data(url) if data is None: return if "value" not in data: logging.info("no work items linked") return for raw in data["value"]: work_item = self.make_work_item(raw) if work_item is not None: self.link_to_pull_request(work_item, pull_request) self.fill_in_the_rest(work_item, graph) transaction = graph.begin() transaction.merge(work_item) transaction.graph.push(work_item)
def crawl(self, pull_request_id): ''' Crawls the comments and puts them in Neo4J ''' graph = GraphBuilder().GetNewGraph() pull_request = PullRequest.select(graph, pull_request_id).first() for repo in pull_request.ForRepository: self.copy_over_comments(repo.Id, pull_request) print("finished adding comments")
def get_pull_request_neo4j(self, graph, pull_req_id): """ loads an existing Neo4j pull request or creates a new bare minimum one in the database :param graph: py2neo PullRequest :returns: from Neo4j either a new or existing PullRequest """ pull = PullRequest.select(graph, pull_req_id).first() if pull is None: pull = PullRequest() pull.Id = pull_req_id graph.create(pull) return pull