diff --git a/swh-team/swh-weekly-report b/swh-team/swh-weekly-report index e8237df..c8caaa2 100755 --- a/swh-team/swh-weekly-report +++ b/swh-team/swh-weekly-report @@ -1,88 +1,88 @@ #!/usr/bin/python3 # Depends: python3-click, python3-phabricator import click from datetime import datetime from dateutil.relativedelta import relativedelta from phabricator import Phabricator from swhphab import paginate, whoami from swhphab import print_commits, print_tasks, print_reviews def list_tasks(phab, newer_than): """list subscribed tasks, modified after given timestamp Args: phab: Phabricator instance newer_than: time limit, as seconds sync epoch """ r = phab.maniphest.search(queryKey='subscribed', constraints={'modifiedStart': newer_than}, order='updated') return [task for task in r['data']] def list_commits(phab, newer_than): """list authored commits newer than given timestamp Args: phab: Phabricator instance newer_than: time limit, as seconds sync epoch """ return paginate(phab.diffusion.commit.search, {'queryKey': 'authored', 'order': 'newest'}, - lambda c: c['fields']['author']['epoch'] <= newer_than) + lambda c: c['fields']['committer']['epoch'] <= newer_than) def list_reviews(phab, newer_than): def recent(c): return c['fields']['dateModified'] <= newer_than authored = paginate(phab.differential.revision.search, {'queryKey': 'authored', 'order': 'updated'}, recent) subscribed = paginate(phab.differential.revision.search, {'constraints': {'subscribers': [whoami(phab)]}, 'order': 'updated'}, recent) return authored + [r for r in subscribed if r not in authored] @click.command() @click.option('--days', '-d', default=7, show_default=True, type=int, help='Look for events no older than N days') @click.option('--tasks/--no-tasks', default=True, show_default=True, help='list tasks') @click.option('--commits/--no-commits', default=True, show_default=True, help='list commits') @click.option('--reviews/--no-reviews', default=True, show_default=True, help='list reviews') def main(days, tasks, commits, reviews): phab = Phabricator() phab.update_interfaces() query = {'newer_than': int((datetime.now() + relativedelta(days=-days)).timestamp())} print() if tasks: print('Tasks (subscribed):') print_tasks(phab, list_tasks(phab, **query)) print() if commits: print('Commits (authored):') print_commits(phab, list_commits(phab, **query)) print() if reviews: print('Reviews (authored & subscribed):') print_reviews(phab, list_reviews(phab, **query)) print() if __name__ == '__main__': main()