Page MenuHomePhabricator

Identify archived projects with tasks open that have no other projects assigned
Closed, ResolvedPublic

Description

As this is a recurring issue

enhance the weekly changes script accordingly, so I could (create tasks about) clean up rotting ancient tasks.

Event Timeline

Good idea, also useful for our sprints, hackathons, and outreach programs. I try to assure that no tasks with other projects associated are left when archiving these projects, but this is just too prone to miss tasks.

Aklapper added a subscriber: Krenair.

My brain capacity (and SQL skills) to come up with a proper sub-query to only have output like "name of archived project, number of open tasks associated with only that project" is limited today.
Hence dropping an incomplete quick shot:

Get number of open tasks per archived project (ignores whether another project is associated):

SELECT p.name, count(p.name) AS n FROM phabricator_maniphest.edge edg JOIN phabricator_maniphest.maniphest_task t JOIN phabricator_project.project p 
WHERE edg.dst LIKE 'PHID-PROJ-%' AND edg.src LIKE 'PHID-TASK-%' AND p.phid = edg.dst AND p.status = 100 AND t.phid = edg.src AND (t.status = "open" OR t.status = "stalled") 
GROUP BY p.name ORDER BY n DESC;

Get task IDs and associated project name for open tasks with exactly one associated archived project:

SELECT p.name, t.id FROM phabricator_maniphest.edge edg JOIN phabricator_maniphest.maniphest_task t JOIN phabricator_project.project p
WHERE edg.dst LIKE 'PHID-PROJ-%' AND edg.src LIKE 'PHID-TASK-%' AND p.phid = edg.dst AND p.status = 100 AND t.phid = edg.src AND (t.status = "open" OR t.status = "stalled")  
GROUP BY edg.src HAVING (COUNT(edg.src) = 1);

For better understanding: p.status = 100 means archived. Checking both the edg.src (task phid in our case) and edg.dst (project phid in our case) values is needed as we do not want to include results about tasks being mentioned in other tasks.

Would also love to exclude Patch-For-Review (PHID-PROJ-onnxucoedheq3jevknyr) but then having both HAVING (COUNT(edg.src) = 1) and SELECT edg.dst won't work anymore obviously.

Writing SQL queries in the park without a machine around was surprisingly successful.

SELECT p.name, count(p.name) AS n 
FROM phabricator_maniphest.edge edg 
JOIN phabricator_maniphest.maniphest_task t 
JOIN phabricator_project.project p 
WHERE edg.dst LIKE 'PHID-PROJ-%' 
AND edg.src LIKE 'PHID-TASK-%' 
AND p.phid = edg.dst 
AND p.status = 100 
AND t.phid = edg.src 
AND (t.status = "open" OR t.status = "stalled") 
AND edg.src NOT IN 
(SELECT edg2.src 
FROM phabricator_maniphest.edge edg2 
JOIN phabricator_maniphest.maniphest_task t2 
JOIN phabricator_project.project p2 
WHERE edg2.dst LIKE 'PHID-PROJ-%' 
AND edg2.src LIKE 'PHID-TASK-%' 
AND edg2.dst != "PHID-PROJ-onnxucoedheq3jevknyr" 
AND p2.phid = edg2.dst 
AND p2.status = 0 
AND t2.phid = edg2.src 
AND (t2.status = "open" OR t2.status = "stalled")) 
GROUP BY p.name 
ORDER BY n DESC;

Query output is the name of archived project and number of associated tasks with no other active projects associated && ignoring Patch-For-Review.

Change 291781 had a related patch set uploaded (by Aklapper):
Weekly Phabricator email: List archived projects with open tasks

https://gerrit.wikimedia.org/r/291781

Perhaps offtopic, but where is the mail being sent? I don't remeber seeing it in my mailbox and I'd like to have it delivered.

@Aklapper thanks. Please add my Phabricator email address there as well, thank you.

Puppet changes need to be processed by people with ops rights, no one on this task has that. You can upload a patch for review and then try putting it up for puppet swat I guess.

I am wondering what "archiving" means in this context. What is actually changed when this action happens for a project?

@Danny_B I can add you. Which email address do you want to use? note that it's gonna be in public code

I am wondering what "archiving" means in this context. What is actually changed when this action happens for a project?

Project tag displays grey.
Project name isn't suggested in typeahead unless what you typed is not common with any other open project.

I would assume (not verified though) that changes in archived project's tasks are no longer notified to such project watchers.

Change 292065 had a related patch set uploaded (by Dzahn):
phabricator: send maintenance mail to list not individuals

https://gerrit.wikimedia.org/r/292065

Change 292065 merged by Dzahn:
phabricator: send maintenance mail to list not individuals

https://gerrit.wikimedia.org/r/292065

+--------------------------------------------------------------------------+----+
| name                                                                     | n  |
+--------------------------------------------------------------------------+----+
| MediaWiki-extensions-VectorBeta                                          | 13 |
| Compact-Personal-Bar-(Beta)                                              | 11 |
| Mobile App Sprint 52 - iOS                                               |  8 |
| FINCH                                                                    |  7 |
| Wikimedia-AcaWiki                                                        |  7 |
| Wikimedia-Developer-Summit-2016                                          |  7 |
| Mobile-App-Sprint-53-iOS                                                 |  7 |
| MediaWiki-extensions-SemanticBundle                                      |  6 |
| Chemical-Markup                                                          |  4 |
| MediaWiki-extensions-MirrorTools                                         |  4 |
| Mobile-App-Sprint-54-iOS                                                 |  3 |
| Mobile-App-Sprint-55-iOS                                                 |  3 |
| Mobile-App-Sprint-58-iOS                                                 |  3 |
| Wikimedia-Developer-Summit-2016-Organization                             |  2 |
| Article-Translation-Metrics                                              |  2 |
| Wikimedia-Hackathon-2015                                                 |  2 |
| Multimedia-Sprint-2015-03-25                                             |  1 |
| Wikimedia-lucene-search-2                                                |  1 |
| Wikimedia-Hackathon-2015-App-Prep                                        |  1 |
| MediaWiki-extensions-Wikilog                                             |  1 |
| Mobile-App-Sprint-56-iOS                                                 |  1 |
| Wikipedia-App-Near-by                                                    |  1 |
| Wikimedia-Hackathon-2016                                                 |  1 |
| MobileFrontend-beta                                                      |  1 |
| Google-Code-In-2015                                                      |  1 |
| Reading-Web-Sprint-65-Game of Phones                                     |  1 |
| Reading-Web-Sprint-70-Lady-and-the-Trumps                                |  1 |
| Reading-Web-Sprint-71-Matisse-Monet-Kandinsky-and-the-Departing-Painters |  1 |
| Mobile App Sprint 52 - Android                                           |  1 |
+--------------------------------------------------------------------------+----+
29 rows in set (1.53 sec)

Change 291781 merged by Dzahn:
Weekly Phabricator email: List archived projects with open tasks

https://gerrit.wikimedia.org/r/291781

I confirmed that user can run it, it takes about 1.5 seconds and then merged Andre's change and ran the script one more time, you should have received it in email too now

Dzahn removed a project: Patch-For-Review.

I've cleaned up (tagged with other project / closed) Article-Translation-Metrics and all projects with 1 occurence except for T95914: Outreach to CocoaHeads

This is very useful, thank you!