add uploaders to the participants in a review
Count folks who upload revisions to patches separately from the original owner of the patch. Change-Id: Iacba947b86aa836fce36a7545df2800ad2d467ec Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
161b6e9be6
commit
a479f92888
@ -108,6 +108,7 @@ class Review:
|
||||
def participants(self):
|
||||
yield self.owner
|
||||
yield from self.reviewers
|
||||
yield from self.uploaders
|
||||
|
||||
@property
|
||||
def owner(self):
|
||||
@ -119,6 +120,39 @@ class Review:
|
||||
self.created,
|
||||
)
|
||||
|
||||
@property
|
||||
def uploaders(self):
|
||||
known_uploaders = set()
|
||||
|
||||
# Record the owner of the patch as a known uploader so we do
|
||||
# not emit their information again. This means someone with
|
||||
# the "uploader" role can be counted as someone taking over a
|
||||
# patch created by someone else to fix it in some way.
|
||||
owner_email = self._data['owner']['email']
|
||||
known_uploaders.add(owner_email)
|
||||
|
||||
# The revision data is stored in a mapping keyed by the SHA,
|
||||
# so in order to be consistent with how we return the
|
||||
# uploaders we sort the revisions based on the number before
|
||||
# we process them.
|
||||
revisions = sorted(
|
||||
self._data['revisions'].values(),
|
||||
key=lambda x: x['_number'],
|
||||
)
|
||||
|
||||
for revision in revisions:
|
||||
uploader = revision['uploader']
|
||||
if uploader['email'] in known_uploaders:
|
||||
# Ignore duplicates
|
||||
continue
|
||||
known_uploaders.add(uploader['email'])
|
||||
yield Participant(
|
||||
'uploader',
|
||||
uploader['name'],
|
||||
uploader['email'],
|
||||
_to_datetime(revision['created']),
|
||||
)
|
||||
|
||||
@property
|
||||
def reviewers(self):
|
||||
labels = self._data['labels']
|
||||
|
@ -133,6 +133,24 @@ class TestReview(base.TestCase):
|
||||
]
|
||||
self.assertEqual(expected, reviewers)
|
||||
|
||||
def test_uploaders(self):
|
||||
uploaders = list(self.rev.uploaders)
|
||||
expected = [
|
||||
gerrit.Participant(
|
||||
role='uploader',
|
||||
name='Hiroaki Kobayashi',
|
||||
email='kobayashi.hiroaki@lab.ntt.co.jp',
|
||||
date=datetime.datetime(2018, 4, 10, 6, 7, 47),
|
||||
),
|
||||
gerrit.Participant(
|
||||
role='uploader',
|
||||
name='Akihiro Motoki',
|
||||
email='amotoki@gmail.com',
|
||||
date=datetime.datetime(2018, 4, 22, 2, 28, 56),
|
||||
),
|
||||
]
|
||||
self.assertEqual(expected, uploaders)
|
||||
|
||||
|
||||
class TestFetchReview(base.TestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user