2019-11-22 22:19:59 +01:00
|
|
|
from lib import Client
|
|
|
|
|
|
|
|
|
|
|
|
class Checker():
|
|
|
|
def __init__(self, work, client):
|
|
|
|
self.work = work
|
|
|
|
self.client = client
|
|
|
|
|
|
|
|
def phid_check(self, phid):
|
|
|
|
if self.work.get('projects'):
|
|
|
|
return self.phid_check_project(
|
|
|
|
phid, [
|
|
|
|
self.client.lookupPhid(
|
|
|
|
'#' + i) for i in self.work['projects']])
|
|
|
|
if self.work.get('status'):
|
|
|
|
return self.phid_check_status(phid, self.work['status'])
|
|
|
|
return False
|
|
|
|
|
|
|
|
def phid_check_project(self, phid, project_phids):
|
|
|
|
taskDetails = self.client.taskDetails(phid)
|
|
|
|
for project_phid in project_phids:
|
|
|
|
if project_phid in taskDetails['projectPHIDs']:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def phid_check_status(self, phid, statuses):
|
|
|
|
taskDetails = self.client.taskDetails(phid)
|
|
|
|
return taskDetails['statusName'] in statuses
|
|
|
|
|
|
|
|
|
|
|
|
client = Client.newFromCreds()
|
|
|
|
|
|
|
|
work = [{'from': ['incoming'],
|
|
|
|
'project': 'Wikidata',
|
|
|
|
'to': 'in progress',
|
|
|
|
'projects': ['wikidata-campsite-iteration-∞',
|
2020-07-15 16:28:47 +02:00
|
|
|
'Wikibase_Extension_Decoupling_and_Registration',
|
2019-11-22 22:19:59 +01:00
|
|
|
'wikidata-bridge-sprint-8']},
|
2021-03-12 10:31:11 +01:00
|
|
|
{'from': ['Test (Verification)'],
|
|
|
|
'project': 'wikidata-campsite-iteration-∞',
|
|
|
|
'to': 'Done',
|
|
|
|
'status': ['Resolved']},
|
2022-04-22 09:59:21 +02:00
|
|
|
{'from': ['Inbox','Investigate & Discuss','Blocked','Goals','To Prioritize','Triaged Low (0-50)', 'Triaged Medium (50+)','Triaged Big','Active','Subtasks'],
|
2021-04-23 12:57:34 +02:00
|
|
|
'project': 'wdwb-tech',
|
2022-04-22 09:59:21 +02:00
|
|
|
'to': 'Sorted Team A',
|
|
|
|
'projects': ['wmde-team-a-tech']},
|
|
|
|
{'from': ['Inbox','Investigate & Discuss','Blocked','Goals','To Prioritize','Triaged Low (0-50)', 'Triaged Medium (50+)','Triaged Big','Active','Subtasks'],
|
|
|
|
'project': 'wdwb-tech',
|
|
|
|
'to': 'Sorted Team B',
|
|
|
|
'projects': ['wmde-team-b-tech']},
|
2022-03-08 12:43:56 +01:00
|
|
|
{'from': ['In progress'],
|
|
|
|
'project': 'DBA',
|
|
|
|
'to': 'Done',
|
|
|
|
'status': ['Resolved']},
|
2020-05-15 15:26:19 +02:00
|
|
|
{'from': ['Radar',
|
|
|
|
'Extensions & Core',
|
|
|
|
'Configuration'],
|
2020-03-03 23:53:19 +01:00
|
|
|
'project': 'User-RhinosF1',
|
2020-03-03 23:35:08 +01:00
|
|
|
'to': 'Done',
|
|
|
|
'status': ['Resolved']},
|
2021-09-25 23:31:43 +02:00
|
|
|
{'from': ['Backlog',
|
|
|
|
'Language conversion',
|
|
|
|
'Site configuration'],
|
|
|
|
'project': 'Bengali-Sites',
|
|
|
|
'to': 'Done',
|
2023-04-20 16:45:02 +02:00
|
|
|
'status': ['Resolved']},
|
2022-09-29 11:57:13 +02:00
|
|
|
{'from': ['New Tasks',
|
|
|
|
'Backlog',
|
|
|
|
'Prioritized'],
|
|
|
|
'project': 'growthexperiments-mentorship',
|
|
|
|
'to': 'In Progress',
|
2023-10-02 14:39:31 +02:00
|
|
|
'projects': ['growth-team-current-sprint']},
|
|
|
|
{'from': ['Incoming',
|
|
|
|
'Radar',
|
|
|
|
'Other Projects',
|
|
|
|
'[DOT] By Project',
|
|
|
|
'[DOT] Prioritized',
|
|
|
|
'[DOT] Epics + Stalled'
|
|
|
|
'[QT] By Project',
|
|
|
|
'[QT] Prioritized',
|
|
|
|
'[QT] Epics + Stalled'],
|
|
|
|
'project': 'wmde-wikidata-tech',
|
|
|
|
'to': 'Ongoing',
|
|
|
|
'projects': [
|
|
|
|
'wikidata_dev_team_wikidata.org',
|
|
|
|
'wikidata_dev_team_quality_tools',
|
|
|
|
'wikidata_dev_team_sprint']}
|
2020-03-03 23:35:08 +01:00
|
|
|
]
|
2019-11-22 22:19:59 +01:00
|
|
|
for case in work:
|
|
|
|
gen = client.getTasksWithProject(client.lookupPhid('#' + case['project']))
|
|
|
|
checker = Checker(case, client)
|
|
|
|
columns = client.getColumns(client.lookupPhid('#' + case['project']))
|
|
|
|
mapping = {}
|
|
|
|
for column in columns['data']:
|
|
|
|
mapping[column['fields']['name']] = column['phid']
|
|
|
|
for phid in gen:
|
|
|
|
if checker.phid_check(phid):
|
|
|
|
project_phid = client.lookupPhid('#' + case['project'])
|
|
|
|
currentColumnName = client.getTaskColumns(
|
|
|
|
phid)['boards'][project_phid]['columns'][0]['name']
|
|
|
|
if currentColumnName not in case['from']:
|
|
|
|
continue
|
|
|
|
try:
|
|
|
|
print(phid)
|
|
|
|
client.moveColumns(phid, mapping[case['to']])
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
continue
|