Skip to content

Commit

Permalink
Refactor getting review data with API v4
Browse files Browse the repository at this point in the history
Refactored `app.py` to have the getting of data from GitLab using version
4 of the API in its own function. This will help to support GraphQL in
parallel later.
  • Loading branch information
Simon-1-1 committed Dec 29, 2023
1 parent a38874a commit 1fca79b
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions reviewcheck/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,13 @@ def write_viewed_message_ids(new_comment_note_ids: Set[str]) -> None:
f.write(f"{id}\n")


def show_reviews(config: Dict[str, Any], suppress_notifications: bool) -> None:
"""Download MR data and present review info for each relevant MR.
:param config: The resolved configuration of reviewcheck.
"""
def apiv4_reviews(config: Dict[str, Any]) -> List[MergeRequest]:
"""Get review data using Gitlab API v4."""
secret_token = config["secret_token"]
api_url = config["api_url"]
jira_url = config["jira_url"]
project_ids = config["project_ids"]
user = config["user"]
ignored_mrs = config["ignored_mrs"]
show_all_discussions = config["show_all_discussions"]
hide_all_threads_user_already_replied_to = config["hide_replied_discussions"]

mr_pages = []
with Progress(transient=True, expand=True) as progress:
gitlab_download_task = progress.add_task(
Expand Down Expand Up @@ -146,6 +139,24 @@ def mr_url(project: str, id: str) -> str:
)
)
progress.update(gitlab_download_task, advance=1)
return mrs


def get_review_data(config: Dict[str, Any]) -> List[MergeRequest]:
"""Get review data from GitLab based on configuration."""
return apiv4_reviews(config)


def show_reviews(config: Dict[str, Any], suppress_notifications: bool) -> None:
"""Download MR data and present review info for each relevant MR.
:param config: The resolved configuration of reviewcheck.
"""
jira_url = config["jira_url"]
show_all_discussions = config["show_all_discussions"]
hide_all_threads_user_already_replied_to = config["hide_replied_discussions"]
user = config["user"]
mrs = get_review_data(config)

console.print(
Panel(
Expand Down

0 comments on commit 1fca79b

Please sign in to comment.