Page MenuHomePhabricator

[keyserver] Add num revisions reviewed to monthly Phabricator leaderboard
ClosedPublic

Authored by ashoat on Dec 28 2023, 7:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 4 2024, 12:31 PM
Unknown Object (File)
Apr 4 2024, 12:31 PM
Unknown Object (File)
Apr 4 2024, 12:31 PM
Unknown Object (File)
Apr 4 2024, 12:31 PM
Unknown Object (File)
Apr 4 2024, 12:29 PM
Unknown Object (File)
Apr 4 2024, 12:28 PM
Unknown Object (File)
Feb 22 2024, 9:43 AM
Unknown Object (File)
Feb 22 2024, 9:37 AM
Subscribers

Details

Summary

This adds a query for the number of revisions reviewed. It's there for both the monthly stats and the yearly stats.

Linear task: ENG-6306

Depends on D10477

Test Plan
  1. I created a Phabricator leaderboard thread in my local environment
  2. I changed phabLeaderboardChannel with the value of that thread ID
  3. I patched postLeaderboard to test the behavior on January 2024
  4. yarn script dist/scripts/phab-leaderboard.js

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

keyserver/src/cron/phab-leaderboard.js
150–161 ↗(On Diff #35047)

This is arguably the most complex query here because the double nesting.

The innermost query here is necessary because we want one row for each "action". Phabricator creates multiple rows when you eg. add a comment AND request changes, but we need to be able to see those combined so we can differentiate from somebody resigning with a review, versus just resigning (without reviewing)

JSON_ARRAYAGG lets us create an array with a list of the actions that were taken

164–172 ↗(On Diff #35047)

In the second inner query, we try to filter to only those actions that constitute a proper review.

The first condition excludes "simple resignations", which are when somebody resigns without any inline comments.

The second condition looks to see if a review was made. Phabricator's transactions table includes entries for eg. referencing this diff in another diff, so we have to exclude those.

The three actions we're looking for in the second condition are:

  1. Any inline comment
  2. Any non-inline comment
  3. Any status change (such as accepting or rejecting a diff)

I should also check to see if eg. accepting a diff when you're not blocking yields a "differential.revision.status". If not, I'll need to add some more ORs here for accepting or rejecting

Include accepts / reject when revision status doesn't change

keyserver/src/cron/phab-leaderboard.js
148–161 ↗(On Diff #35048)

This is arguably the most complex query here because the double nesting.

The innermost query here is necessary because we want one row for each "action". Phabricator creates multiple rows when you eg. add a comment AND request changes, but we need to be able to see those combined so we can differentiate from somebody resigning with a review, versus just resigning (without reviewing)

JSON_ARRAYAGG lets us create an array with a list of the actions that were taken

164–174 ↗(On Diff #35048)

In the second inner query, we try to filter to only those actions that constitute a proper review.

The first condition excludes "simple resignations", which are when somebody resigns without any inline comments.

The second condition looks to see if a review was made. Phabricator's transactions table includes entries for eg. referencing this diff in another diff, so we have to exclude those.

The five actions we're looking for in the second condition are:

  1. Any inline comment
  2. Any non-inline comment
  3. Accepting a diff
  4. Rejecting a diff
  5. Any status change (such as adding somebody as blocking)
keyserver/src/cron/phab-leaderboard.js
164–174 ↗(On Diff #35048)

Open to removing differential.revision.status, actually... it barely changes the numbers, and arguably a status change without an accompanying comment / accept / reject doesn't really count as a review

Looks good


(FWIW, you can get an array of transactions for any differential revision with transaction.search endpoint):

68b3cc.png (1×1 px, 348 KB)

This revision is now accepted and ready to land.Dec 28 2023, 5:25 PM

Remove differential.revision.status

This revision was landed with ongoing or failed builds.Dec 28 2023, 6:40 PM
This revision was automatically updated to reflect the committed changes.