diff --git a/lib.py b/lib.py index 665ac62..4caac7c 100755 --- a/lib.py +++ b/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): r = self._getTasksWithProjectContinue( project_phid, continue_, statuses=statuses) @@ -165,6 +180,22 @@ class Client(object): project_phid, cursor['after'], statuses=statuses): 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): params = { 'limit': 100, @@ -201,6 +232,15 @@ class Client(object): return self.post('maniphest.search', params)[ 'data'] + def getTaskName(self, keyword): + params = { + "constraints": { + "query": keyword + } + } + return self.post('maniphest.search', params)[ + 'data'] + def getTaskParents(self, phid): params = { "constraints": { diff --git a/user_notice_archiver.py b/user_notice_archiver.py new file mode 100755 index 0000000..f2fcf40 --- /dev/null +++ b/user_notice_archiver.py @@ -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')