forked from Ladsgroup/Phabricator-maintenance-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_grouper.py
330 lines (325 loc) · 9.64 KB
/
project_grouper.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
"""
Adds tasks in configured projects to other configured projects
"""
from lib import Client
# To get it on a list run this on herald rule page
# const items = document.getElementsByClassName('herald-list-item')[0].getElementsByClassName('phui-handle')
# for (i in items) {console.log(items[i].text)};
rules = [
{
# H175 - see T136921
'add': 'Design',
'in': ['WMF-Design', 'WMDE-Design'],
},
{
# H232
'add': 'artificial-intelligence',
'in': ['editquality-modeling', 'draftquality-modeling', 'articlequality-modeling', 'revscoring'],
},
{
# H193 - see T146701
'add': 'accessibility',
'in': ['ios-app-feature-accessibility'],
},
{
# H174
'add': 'upstream',
'in': ['phabricator-upstream'],
},
{
# H24 - see T86536
'add': 'universallanguageselector',
'in': ['uls-compactlinks'],
},
{
# H15 - note that #producrement tasks are private -> rule can't be disabled
'add': 'SRE',
'in': [
'ops-eqiad',
'ops-codfw',
'ops-esams',
'ops-ulsfo',
# 'hardware-requests', archived project
'SRE-Access-Requests',
'netops',
'vm-requests',
'Traffic',
'ops-eqord',
'ops-eqdfw',
# 'procurement', always in S4
'ops-eqsin',
'DNS',
'LDAP-Access-Requests',
'Wikimedia-Mailing-lists',
],
'once': True
},
{
# H14 - see T85596
'add': 'Social-Tools',
'in': [
'BlogPage',
'Comments',
'FanBoxes',
'LinkFilter',
'PollNY',
'QuizGame',
# 'RandomFeaturedUser', archived project
'RandomGameUnit',
'SocialProfile',
'SiteMetrics',
'VoteNY',
'WikiForum',
'WikiTextLoggedInOut',
'Challenge',
'MiniInvite',
# 'NewUsersList', archived project
'PictureGame',
# 'RandomUsersWithAvatars', archived project
'video_non-wmf',
# 'TopLists', archived project
],
},
{
# H10 - see T76954
'add': 'VisualEditor',
'in': [
'VisualEditor-ContentEditable',
'VisualEditor-ContentLanguage',
'VisualEditor-CopyPaste',
'VisualEditor-DataModel',
'VisualEditor-EditingTools',
'VisualEditor-Initialisation',
'VisualEditor-InterfaceLanguage',
'VisualEditor-MediaWiki',
'VisualEditor-MediaWiki-Links',
'VisualEditor-MediaWiki-Media',
'VisualEditor-MediaWiki-Mobile',
'VisualEditor-MediaWiki-References',
'VisualEditor-MediaWiki-Templates',
'VisualEditor-Performance',
'VisualEditor-Tables',
'TemplateData',
'VisualEditor-MediaWiki-Plugins',
'VisualEditor-LanguageTool',
'VisualEditor-Links',
'VisualEditor-Media',
'VisualEditor-MediaWiki-2017WikitextEditor',
'VisualEditor-VisualDiffs',
],
},
{
'add': 'user-urbanecm-wmf-engineering',
'in': [
'growth-deployments',
]
},
{
# H30
'add': 'wikidata',
'in': [
'Wikibase-Quality-Constraints',
'DataValues',
'DataValues-JavaScript',
'MediaWiki-extensions-WikibaseClient',
'MediaWiki-extensions-WikibaseView',
'Wikibase-DataModel',
'Wikibase-DataModel-JavaScript',
'Wikibase-DataModel-Serialization',
'Wikibase-Internal-Serialization',
'Wikibase-JavaScript-Api',
'Wikibase-Serialization-JavaScript',
'Wikidata-Query-Service',
'Tool-Wikidata-Periodic-Table',
'Wikidata.org',
'DataTypes',
'MediaWiki-extensions-WikibaseRepository',
'SDC General',
'ValueView',
'Wikidata-Gadgets',
'ArticlePlaceholder',
'Wikidata Lexicographical data',
'Automated list generation',
'Wikidata Query UI',
'Wikibase-Containers',
'Soweego',
'Wikidata Mobile',
'Wikidata-Campsite',
'Wikibase-registry',
'wikiba.se website',
'Wikibase-Lua',
'MediaWiki-extensions-PropertySuggester',
'Wikidata-Campsite (Wikidata-Campsite-Iteration-∞)',
'RL Module Terminators Trailblazing',
'Wikidata-Bridge',
'Shape Expressions',
'Wikidata Tainted References',
'Wikidata Design System',
'Wikidata - Reference Treasure Hunt',
'Item Quality Scoring Improvement',
'Wikibase - Automated Configuration Detection (WikibaseManifest)',
'Wikidata Query Builder',
'Wikidata - Visualisation of Reliability Metrics',
'Item Quality Evaluator',
'wdwb-tech',
'Cognate',
'Mismatch Finder',
'Wikidata analytics',
'Wikidata-Termbox',
'Special:NewLexeme revival',
'Wikidata Dev Team',
'Wikidata data quality and trust',
],
'once': True
},
{
'add': 'Wikidata Lexicographical data',
'in': [
'Special:NewLexeme revival',
],
'once': True
},
{
# H337
'add': 'Research',
'in': [
'address-knowledge-gaps',
'Research-foundational',
'Knowledge-Integrity',
],
'once': True
},
{
# H314
'add': 'Pywikibot',
'in': [
'Pywikibot-archivebot.py',
'Pywikibot-category.py',
'Pywikibot-compat',
'Pywikibot-copyright.py',
'Pywikibot-delinker.py',
'Pywikibot-cosmetic-changes.py',
'Pywikibot-Documentation',
'Pywikibot-General',
'Pywikibot-i18n',
'Pywikibot-interwiki.py',
'Pywikibot-login.py',
'Pywikibot-network',
'Pywikibot-Scripts',
'Pywikibot-pagegenerators.py',
'Pywikibot-redirect.py',
'Pywikibot-replace.py',
'Pywikibot-solve-disambiguation.py',
'Pywikibot-tests',
'Pywikibot-textlib.py',
'Pywikibot-weblinkchecker.py',
'Pywikibot-Wikidata',
'Pywikibot-xmlreader.py',
],
'once': True
},
{
# H285
'add': 'Product-Analytics',
'in': [
'Discovery-Analysis',
],
'once': True
},
{
# H216
'add': 'WMDE-FUN-Team',
'in': [
'WMDE-Fundraising-Tech',
],
'once': True
},
{
# H131
'add': 'Traffic',
'in': [
'HTTPS',
'DNS',
'Domains',
],
'once': True
},
{
# H131
'add': 'Traffic',
'in': [
'HTTPS',
'DNS',
'Domains',
],
'once': True
},
{
# H109
'add': 'Commons',
'in': [
'MediaWiki-File-management',
'MediaWiki-extensions-GWToolset',
],
'once': True
},
{
# Keep all Abstract Wikipedia work on the team board
'add': 'abstract_wikipedia',
'in': [
'abstract_wikipedia_ux',
'wikifunctions',
'wikilambda',
'function-evaluator',
'function-orchestrator',
'function-schemata',
],
},
{
# https://phabricator.wikimedia.org/T295397
'add': 'Data-Engineering',
'in': [
'Event-Platform',
'Analytics-Wikistats',
],
'once': True
},
{
'add': 'growthexperiments-mentorship',
'in': [
'growthexperiments-mentordashboard'
],
},
]
client = Client.newFromCreds()
for rule in rules:
handled_tasks = []
wanted_project_phid = client.lookupPhid('#' + rule['add'].replace(' ', '_'))
subprojects = set(client.getSubprojects(wanted_project_phid) + [wanted_project_phid])
for project_name in rule['in']:
project_name = project_name.replace(' ', '_')
try:
project_phid = client.lookupPhid('#' + project_name)
except:
continue
for task_phid in client.getTasksWithProject(project_phid):
# if a task is in multiple 'in' projects, still only process it once
if task_phid in handled_tasks:
continue
task = client.taskDetails(task_phid)
if subprojects.intersection(set(task['projectPHIDs'])):
continue
if rule.get('once') == True:
is_already_added = False
transactions = client.getTransactions(task_phid)
for transaction in transactions:
operations = transaction.get(
'fields', {}).get('operations', [])
for operation in operations:
if operation.get('operation') == 'add' and operation.get('phid') == wanted_project_phid:
is_already_added = True
break
if is_already_added == True:
continue
handled_tasks.append(task_phid)
client.addTaskProject(task_phid, wanted_project_phid)