We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor this function for usage with Gitlab
reviews/reviews/controller.py
Line 107 in 7c14aa1
) return code_review_requests class GitlabPullRequestController: """retrieve and store pull requests.""" def __init__(self) -> None: self.client = GitlabAPI() def retrieve_pull_requests(self, project_id: int, namespace: str) -> Union[Table, None]: """Renders Terminal UI Dashboard""" pull_requests = [] try: pull_requests = self.update_pull_requests(project_id=project_id, namespace=namespace) except RepositoryDoesNotExist: # TODO: refactor this function for usage with Gitlab return render_repository_does_not_exist( title=f"{namespace} does not exist", org="", repository="", ) if not pull_requests: return None # TODO: refactor this function to accept a link return render_pull_request_table( title=namespace, pull_requests=pull_requests, org="", repository="", ) def update_pull_requests(self, project_id: int, namespace: str) -> List[PullRequest]: """Updates repository models.""" def _get_reviews(pull_request: ghPullRequest) -> Dict[str, str]: """Inner function to retrieve reviews for a pull request""" reviews = pull_request.approvals.get() return {reviewer["user"]["username"]: True for reviewer in reviews.approvers} # ProjectMergeRequest pull_requests = self.client.get_pull_requests(project_id=project_id, namespace=namespace) code_review_requests = [] for pull_request in pull_requests: reviews = _get_reviews(pull_request=pull_request) if pull_request.author["username"] == config.GITLAB_USER: approved_by_me = "AUTHOR" else: approved_by_me = reviews.get(config.GITLAB_USER, "") # NOQA: R1721 approved_by_others = any( [True for user, status in reviews.items() if user != config.GITLAB_USER and status == "APPROVED"] ) labels = [Label(name=label) for label in pull_request.labels] code_review_requests.append( PullRequest( number=pull_request.iid, title=pull_request.title, draft=pull_request.draft, additions=0, deletions=0, created_at=datetime.strptime(pull_request.created_at, "%Y-%m-%dT%H:%M:%S.%f%z"), updated_at=datetime.strptime(pull_request.updated_at, "%Y-%m-%dT%H:%M:%S.%f%z"), approved=approved_by_me, approved_by_others=approved_by_others, labels=labels, ) ) return code_review_requests
d90dfb66d0d38412e442383d18ad51680077f10b
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
refactor this function for usage with Gitlab
reviews/reviews/controller.py
Line 107 in 7c14aa1
d90dfb66d0d38412e442383d18ad51680077f10b
The text was updated successfully, but these errors were encountered: