Skip to content

Commit

Permalink
refactors user to author
Browse files Browse the repository at this point in the history
  • Loading branch information
apoclyps committed Feb 6, 2022
1 parent 42a015f commit 5e4f8e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions reviews/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def _get_reviews(pull_request: ghPullRequest) -> Dict[str, str]:
PullRequest(
number=pull_request.number,
title=pull_request.title,
user=pull_request.user.login,
draft=pull_request.draft,
repository_url=f"https://www.github.com/{org}/{repository}",
link=f"https://www.github.com/{org}/{repository}/pull/{pull_request.number}",
additions=pull_request.additions,
deletions=pull_request.deletions,
created_at=pull_request.created_at.astimezone(tz=timezone.utc),
updated_at=pull_request.updated_at.astimezone(tz=timezone.utc),
author=pull_request.user.login,
approved=approved_by_me,
approved_by_others=approved_by_others,
labels=labels,
Expand Down Expand Up @@ -200,7 +200,7 @@ def get_labels(labels: List[str]) -> List[Label]:
PullRequest(
number=pull_request.iid,
title=pull_request.title,
user=pull_request.author['username'],
author=pull_request.author["username"],
draft=pull_request.draft,
additions=0,
deletions=0,
Expand Down
2 changes: 1 addition & 1 deletion reviews/layout/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def render_pull_request_table(
row = [
f"[white]{pr.number} ",
pr.render_title(),
f"[white]{pr.user} ",
f"[white]{pr.render_author()} ",
pr.render_labels(label_colour_map),
]

Expand Down
6 changes: 5 additions & 1 deletion reviews/source_control/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PullRequest:

number: int
title: str
user: str
author: str
draft: bool
repository_url: str
link: str
Expand Down Expand Up @@ -83,6 +83,10 @@ def render_updated_at(self, since: Optional[datetime] = None) -> str:

return f"{colour}{humanize.naturaltime(self.updated_at, when=now)}{suffix}"

def render_author(self) -> str:
"""Renders the author as a colourised string"""
return f"[grey]{self.author}[/]"

def render_diff(self) -> str:
"""Renders the additions and deletions using the Github convention of +/-"""
return f"[green]+{self.additions}[/green] [red]-{self.deletions}[/red]"

0 comments on commit 5e4f8e1

Please sign in to comment.