def __init__(self, commit_id: str): """ init for commit :param str commit_id: the identifier for this commit """ self.object_type: base.ObjectType = base.ObjectType.COMMIT self.id: str = commit_id self.repository_id: str = None self.author: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.authored_by_committer: bool = False self.total_authors: int = 0 self.authors: [author.Author] = [] self.committer: [author.Author ] = author.Author('', author.AuthorType.UNKNOWN) # mapped to onBehalfOf self.for_organization_id: str = None # for when the code was committed self.create_datetime: datetime = datetime.now() self.push_datetime: datetime = None self.message_headline: str = '' self.message_body: str = '' self.total_comments: int = 0 self.comment_ids: [str] = [] self.total_check_suites: int = 0 self.check_suite_ids: [str] = [] self.tree_id: str = None self.entries: [CommitEntry] = [] self.additions: int = 0 self.deletions: int = 0 self.changed_files: int = 0 self.total_associated_pull_requests: int = 0 self.associated_pull_request_ids: [str] = [] self.state: str = None
def __init__(self, review_id: str, pull_request_id: str): """ init for a review of a pull request :param str review_id: the identifier for the pull request :param PullRequest pr: the pull request this review pertains to """ self.object_type: base.ObjectType = base.ObjectType.PULL_REQUEST_REVIEW self.id: str = review_id self.pull_request_id: str = pull_request_id self.repository_id: str = None self.author: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.author_association: str = '' self.create_datetime: datetime = datetime.now() self.commit_id: str = None self.body_text: str = '' self.total_edits: int = 0 self.edits: [content.ContentEdit] = [] self.total_reactions: int = 0 self.reactions: [content.Reaction] = [] self.total_comments: int = 0 self.comment_ids: [str] = [] # mapped to onBehalfOf self.total_for_teams: int = 0 self.for_team_ids: [str] = [] self.state: str = None
def __init__(self, request_id: str, repository_id: str): """ init for pull request :param str request_id: the identifier for this request :param str repository_id: the id of the repository this request belongs to """ self.object_type: base.ObjectType = base.ObjectType.PULL_REQUEST self.id: str = request_id self.repository_id: str = repository_id self.author: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.author_association: str = None self.create_datetime: datetime = datetime.now() self.body_text: str = '' self.total_participants: int = 0 self.participants: [author.Author] = [] self.total_comments: int = 0 self.comment_ids: [str] = [] self.total_reviews: int = 0 self.review_ids: [str] = [] self.total_commits: int = 0 self.commit_ids: [str] = [] self.total_edits: int = 0 self.edits: [content.ContentEdit] = [] self.total_reactions: int = 0 self.reactions: [content.Reaction] = [] self.state: str = None
def __init__(self, reaction_id: str): """ init for the reaction :param str reaction_id: identifier for the reaction """ self.id: str = reaction_id self.author: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.create_datetime: datetime = datetime.now() self.content: str = ''
def __init__(self, edit_id: str): """ init for an edit :param str edit_id: the identifier for the edit """ self.id: str = edit_id self.edit_datetime: datetime = datetime.now() self.editor: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.difference: str = '' self.is_delete: bool = False
def __init__(self, comment_id: str): """ init for the base comment :param str comment_id: the identifier for the comment """ self.id: str = comment_id self.repository_id: str = None self.author: author.Author = author.Author('', author.AuthorType.UNKNOWN) self.author_association: str = '' self.create_datetime: datetime = datetime.now() self.body_text: str = '' self.total_reactions: int = 0 self.reactions: [Reaction] = [] self.minimized_status: str = 'NOT MINIMIZED' self.total_edits: int = 0 self.edits: [ContentEdit] = [] self.is_deleted: bool = False
def run(self): """ loads the authors for the commits for a specific repository :return: None """ commits_reviewed: int = 0 commit_count = self._get_objects_saved_count(self.repository, base.ObjectType.COMMIT) commits = self._get_collection().find({ 'repository_id': self.repository.id, 'object_type': base.ObjectType.COMMIT.name }) for commit in commits: commit_id: str = commit['id'] authors_expected: int = commit['total_authors'] authors: [author.Author] = [] author_cursor: str = None commits_reviewed += 1 if authors_expected > len(commit['authors']): while authors_expected > len(authors): logging.debug( f'running query for authors for commit [{commit_id}] against {self.repository}' ) query = self._commit_authors_query(commit_id, author_cursor) response_json = self.graph_ql_client.execute_query(query) logging.debug( f'query complete for authors for commit [{commit_id}] against {self.repository}' ) # iterate over each author returned (we return 100 at a time) for edge in response_json["data"]["node"]["authors"][ "edges"]: author_cursor = edge["cursor"] if edge["node"]["user"] is not None: authors.append( self._find_author_by_id( edge["node"]["user"]["id"])) else: authors.append( author.Author('', author.AuthorType.UNKNOWN)) author_dictionaries = list(map(base.to_dictionary, authors)) self._get_collection().update_one( {'id': commit_id}, {'$set': { 'authors': author_dictionaries }}) logging.debug( f'pull requests reviewed for {self.repository} {commits_reviewed}/{commit_count}' ) actual_count: int = self._get_actual_results() expected_count: int = self._get_expected_results() logging.debug( f'authors returned for {self.repository} returned: [{actual_count}], expected: [{expected_count}]' )