Skip to content
New issue

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

Only count the users latest review #2

Merged

Conversation

mweinelt
Copy link
Member

@mweinelt mweinelt commented Jun 7, 2022

Foxes Inflated review count due to

  • approve
  • comment/request changes
  • approve

as seen in NixOS/nixpkgs#176175

Untested

@mweinelt
Copy link
Member Author

mweinelt commented Jun 7, 2022

Oops, that won't work with later code.

@mweinelt mweinelt force-pushed the duplicate-reviews-and-retractions branch 2 times, most recently from 959cd34 to 459dc40 Compare June 7, 2022 01:28
for review in p_r_reviews:
if review.state == "APPROVED":
approvals[review.user] = review
last_approved_review_date = review.submitted_at
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes the order of reviews is chronologically, which held true during my tests.

@mweinelt
Copy link
Member Author

mweinelt commented Jun 7, 2022

>  label-approved
INFO:root:Pulls total: 8
INFO:root:Processing 176175
INFO:root:lastappdate: 2022-06-04 09:21:32
INFO:root:lastcommitdate: 2022-06-04 02:17:11
INFO:root:Removing label '12.approvals: 2' from PR: '176175' https://github.com/NixOS/nixpkgs/pull/176175
Traceback (most recent call last):
  File "/nix/store/h8s1yi7jvxcb6kblamiy1d8kzni6p3p6-python3.10-poetry2nix-env-scripts/bin/.label-approved-wrapped", line 13, in <module>
    sys.exit(main())
  File "/nix/store/v7kl295wwqxgax6gm3zw95aq5zwcgbzg-source/src/label_approved/cli.py", line 156, in main
    pr_object.p_r.remove_from_labels(label_to_remove)
  File "/nix/store/01h3ndmfxlgf6hklk422alxdzcljadak-python3-3.10.3-env/lib/python3.10/site-packages/github/PullRequest.py", line 809, in remove_from_labels
    headers, data = self._requester.requestJsonAndCheck(
  File "/nix/store/01h3ndmfxlgf6hklk422alxdzcljadak-python3-3.10.3-env/lib/python3.10/site-packages/github/Requester.py", line 353, in requestJsonAndCheck
    return self.__check(
  File "/nix/store/01h3ndmfxlgf6hklk422alxdzcljadak-python3-3.10.3-env/lib/python3.10/site-packages/github/Requester.py", line 378, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 403 {"message": "Must have admin rights to Repository.", "documentation_url": "https://docs.github.com/rest/reference/issues#remove-a-label-from-an-issue"}

@mweinelt
Copy link
Member Author

mweinelt commented Jun 7, 2022

> label-approved
INFO:root:Pulls total: 8
INFO:root:Processing 176175
INFO:root:lastappdate: 2022-06-04 09:21:32
INFO:root:lastcommitdate: 2022-06-04 02:17:11
INFO:root:Removing label '12.approvals: 2' from PR: '176175' https://github.com/NixOS/nixpkgs/pull/176175
INFO:root:Adding label '12.approvals: 1' to PR: '176175' https://github.com/NixOS/nixpkgs/pull/176175

Fixes inflate review count due to a cycle of approve, comment/request
changes, approve.
@mweinelt mweinelt force-pushed the duplicate-reviews-and-retractions branch from 459dc40 to 3ee35bc Compare June 7, 2022 01:41
Copy link
Member

@Artturin Artturin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, i forgot to turn on notifications for all events in this repo

@Artturin Artturin merged commit 5842492 into nix-community:master Jun 9, 2022
@mweinelt mweinelt deleted the duplicate-reviews-and-retractions branch June 9, 2022 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants