Page MenuHomePhabricator
Paste P2454

Find Phab tasks with projects CC'd
ActivePublic

Authored by Krenair on Dec 26 2015, 4:21 AM.
Referenced Files
F3148856: Find Phab tasks with projects CC'd
Feb 24 2016, 5:27 AM
Subscribers
Tokens
"Like" token, awarded by Luke081515.
# By Alex Monk. As of writing, dies around offset 42k due to a server-side timeout.
import json, subprocess
def getAll(arcArgs, params = {}, limit = 1000, offset = 0):
print("Offset " + str(offset))
proc = subprocess.Popen(arcArgs, stdin = subprocess.PIPE, stdout = subprocess.PIPE)
resultOut, resultErr = proc.communicate(input = json.dumps(dict(params, limit = limit, offset = offset)))
dataOut = json.loads(resultOut.strip())['response']
if 'data' in dataOut:
items = dataOut['data'].values()
elif isinstance(dataOut, dict):
items = dataOut.values()
elif isinstance(dataOut, list):
items = dataOut
for item in items:
yield item
if len(items) == limit:
for item in getAll(arcArgs, params = params, limit = limit, offset = offset + limit):
yield item
arcCommand = ['arc', 'call-conduit', '--conduit-uri', 'https://phabricator.wikimedia.org/']
# Security: PHID-PROJ-koo4qqdng27q7r65x3cw
# WMF-NDA: PHID-PROJ-ibxm3v6ithf3jpqpqhl7
# {'projectPHIDs': ['PHID-PROJ-somethingsomethingsomething']}
for task in getAll(arcCommand + ['maniphest.query'], {}, limit = 1000):
for ccPHID in task['ccPHIDs']:
if 'PROJ' in ccPHID:
print('https://phabricator.wikimedia.org/T' + task['id'] + ' - ' + ccPHID + ' - ' + task['title'])
break

Event Timeline

Krenair changed the title of this paste from untitled to Find Phab tasks with projects CC'd.Dec 26 2015, 4:21 AM
Krenair updated the paste's language from autodetect to python.
Krenair edited the content of this paste. (Show Details)
Krenair added a project: Phabricator.
Krenair added a subscriber: Luke081515.