This repository has been archived by the owner on Oct 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
column_mover.py
executable file
·107 lines (99 loc) · 3.97 KB
/
column_mover.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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-∞',
'Wikibase_Extension_Decoupling_and_Registration',
'wikidata-bridge-sprint-8']},
{'from': ['Test (Verification)'],
'project': 'wikidata-campsite-iteration-∞',
'to': 'Done',
'status': ['Resolved']},
{'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 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']},
{'from': ['In progress'],
'project': 'DBA',
'to': 'Done',
'status': ['Resolved']},
{'from': ['Radar',
'Extensions & Core',
'Configuration'],
'project': 'User-RhinosF1',
'to': 'Done',
'status': ['Resolved']},
{'from': ['Backlog',
'Language conversion',
'Site configuration'],
'project': 'Bengali-Sites',
'to': 'Done',
'status': ['Resolved']},
{'from': ['New Tasks',
'Backlog',
'Prioritized'],
'project': 'growthexperiments-mentorship',
'to': 'In Progress',
'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']}
]
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