mirror of
https://gitlab.wikimedia.org/ladsgroup/Phabricator-maintenance-bot
synced 2024-11-21 19:42:38 +01:00
Add user_notice_archiver
To clean up archives of user-notice tag
This commit is contained in:
parent
74733131c8
commit
731184f2be
2 changed files with 53 additions and 0 deletions
40
lib.py
40
lib.py
|
@ -152,6 +152,21 @@ class Client(object):
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def changeProjectByPhid(self, task_phid, old_project_phid, new_project_phid):
|
||||||
|
return self.post('maniphest.edit', {
|
||||||
|
'objectIdentifier': task_phid,
|
||||||
|
'transactions': [{
|
||||||
|
'type': 'projects.remove',
|
||||||
|
'value': [old_project_phid],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'projects.add',
|
||||||
|
'value': [new_project_phid],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
def getTasksWithProject(self, project_phid, continue_=None, statuses=None):
|
def getTasksWithProject(self, project_phid, continue_=None, statuses=None):
|
||||||
r = self._getTasksWithProjectContinue(
|
r = self._getTasksWithProjectContinue(
|
||||||
project_phid, continue_, statuses=statuses)
|
project_phid, continue_, statuses=statuses)
|
||||||
|
@ -165,6 +180,22 @@ class Client(object):
|
||||||
project_phid, cursor['after'], statuses=statuses):
|
project_phid, cursor['after'], statuses=statuses):
|
||||||
yield case
|
yield case
|
||||||
|
|
||||||
|
def getInactiveTasksWithProject(self, project_phid, inactive_for=864000, statuses=['resolved'], columns=[]):
|
||||||
|
params = {
|
||||||
|
'limit': 100,
|
||||||
|
'constraints': {
|
||||||
|
'projects': [project_phid],
|
||||||
|
'statuses': statuses,
|
||||||
|
"modifiedEnd": int(time.time() - inactive_for),
|
||||||
|
'columnPHIDs': columns,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r = self.post('maniphest.search', params)
|
||||||
|
for case in r['data']:
|
||||||
|
if case['type'] != 'TASK':
|
||||||
|
continue
|
||||||
|
yield case['phid']
|
||||||
|
|
||||||
def _getTasksWithProjectContinue(self, project_phid, continue_=None, statuses=None):
|
def _getTasksWithProjectContinue(self, project_phid, continue_=None, statuses=None):
|
||||||
params = {
|
params = {
|
||||||
'limit': 100,
|
'limit': 100,
|
||||||
|
@ -201,6 +232,15 @@ class Client(object):
|
||||||
return self.post('maniphest.search', params)[
|
return self.post('maniphest.search', params)[
|
||||||
'data']
|
'data']
|
||||||
|
|
||||||
|
def getTaskName(self, keyword):
|
||||||
|
params = {
|
||||||
|
"constraints": {
|
||||||
|
"query": keyword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self.post('maniphest.search', params)[
|
||||||
|
'data']
|
||||||
|
|
||||||
def getTaskParents(self, phid):
|
def getTaskParents(self, phid):
|
||||||
params = {
|
params = {
|
||||||
"constraints": {
|
"constraints": {
|
||||||
|
|
13
user_notice_archiver.py
Executable file
13
user_notice_archiver.py
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
from lib import Client
|
||||||
|
|
||||||
|
|
||||||
|
client = Client.newFromCreds()
|
||||||
|
|
||||||
|
user_notice_phid = client.lookupPhid('#user-notice')
|
||||||
|
columns = client.getColumns(user_notice_phid)
|
||||||
|
mapping = {}
|
||||||
|
for column in columns['data']:
|
||||||
|
mapping[column['fields']['name']] = column['phid']
|
||||||
|
gen = client.getInactiveTasksWithProject(user_notice_phid, columns=[mapping['Already announced/Archive']])
|
||||||
|
for phid in gen:
|
||||||
|
client.changeProjectByPhid(phid, user_notice_phid, 'PHID-PROJ-y6egyt5y4lvnzs5mgll6')
|
Loading…
Reference in a new issue