Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8391969
swh-weekly-report
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
swh-weekly-report
View Options
#!/usr/bin/env 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'
][
'committer'
][
'epoch'
]
<=
newer_than
)
def
list_reviews
(
phab
,
newer_than
):
def
recent
(
c
):
return
c
[
'fields'
][
'dateModified'
]
<=
newer_than
authored
=
list
(
paginate
(
phab
.
differential
.
revision
.
search
,
{
'queryKey'
:
'authored'
,
'order'
:
'updated'
},
recent
))
subscribed
=
list
(
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
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Jun 4 2025, 6:52 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3240301
Attached To
rDSNIP Code snippets
Event Timeline
Log In to Comment