Page MenuHomePhabricator

"Project creation/edits log" cronjob email for Phab admins
Closed, ResolvedPublic

Description

Bugzilla admins received a custom daily email (cronjob) that listed recent changes (new accounts created, projects created/renamed/changed).
Once it existed (after Bugzilla 4.2 only), it was helpful to identify and avoid duplication of certain efforts or inconcistency.

In Phabricator, getting a better overview which projects get created and guideline application can be helpful, as we have many people in the ProjectCreators group who can perform such actions.

In the phabricator_project DB:

SELECT name, editPolicy, viewPolicy, editPolicy, joinPolicy, icon, color, status FROM project WHERE FROM_UNIXTIME(dateModified,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');

Status: 0 = Active; 100 = Archived.
The rest of the values is self-explaining.

Event Timeline

Aklapper claimed this task.
Aklapper raised the priority of this task from to Low.
Aklapper updated the task description. (Show Details)
Aklapper added a project: Phabricator.
Aklapper subscribed.

I guess the advantage of a cronjob email is that we can create it for this instance without bothering upstream?

It looks like Phabricator should include a feature to receive a notification via subscription or Herald whenever a new project is created. Even the possibility to sort projects by creation date would help, but only alphabetical sorting is available.

Not to myself: Might want to extend to also cover "newly created workboards" to get a list of column names.

Aklapper renamed this task from "Project creation log" cronjob email for Phab admins to "Project creation/edits log" cronjob email for Phab admins.Apr 13 2015, 12:00 PM
Aklapper set Security to None.

Seems like the last Phabricator upgrade brought email notification emails about Project creations and changes. Nice.

Still need to check a bit more which stuff they don't cover, why I get them, and if I maybe don't get some change notifications.

Change 233219 had a related patch set uploaded (by Aklapper):
[WIP] Phabricator project creation/changes log email for Phab admins

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

In T85183#946843, @Qgil wrote:

I guess the advantage of a cronjob email is that we can create it for this instance without bothering upstream?

Yes. Quick and dirty, and I've recently been quite unhappy when discovering newly created projects violating our project creation guidelines.

As I'm after recent changes, the query I posted above above isn't too helpful. Instead here are the SQL queries which I used in the linked patchset:

Project creations and project name changes in the last 7 days:
[phabricator_project] SELECT oldValue, newValue FROM project_transaction WHERE transactionType = "project:name" AND dateModified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK));

Project color changes in the last 7 days:
[phabricator_project] SELECT project_transaction.oldValue, project_transaction.newValue, project.name FROM project_transaction JOIN project WHERE project_transaction.transactionType = "project:color" AND project_transaction.objectPHID = project.phid AND project_transaction.dateModified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK));

Project policy/locking/archiving changes in the last 7 days:
[phabricator_project] SELECT project_transaction.oldValue, project_transaction.newValue, project_transaction.transactionType, project.name FROM project_transaction JOIN project WHERE (project_transaction.transactionType = "core:join-policy" OR project_transaction.transactionType = "core:edit-policy" OR project_transaction.transactionType = "core:view-policy" OR project_transaction.transactionType = "project:locked" OR project_transaction.transactionType = "project:status") AND project_transaction.objectPHID = project.phid AND project_transaction.dateModified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK));

Note to myself: Might want to extend to also cover "newly created workboards" to get a list of column names.

Not this time as I consider this less of an issue, but just to document one related SQL query for anybody interested:

Project workboard columns created or renamed in the last 7 days (and who performed that):
SELECT cltr.oldValue, cltr.newValue, prj.name, usr.userName FROM phabricator_project.project_columntransaction cltr JOIN phabricator_project.project prj JOIN phabricator_project.project_column pcl JOIN phabricator_user.user usr WHERE cltr.transactionType = "project:col:name" AND cltr.objectPHID = pcl.phid AND pcl.projectPHID = prj.phid AND cltr.authorPHID = usr.phid AND cltr.dateModified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK));

Change 233219 merged by Dzahn:
Phabricator project creation/changes log email for Phab admins

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

I tested the puppet part in compiler http://puppet-compiler.wmflabs.org/871/

applied it on iridium, cron has been created

I ran /usr/local/bin/project_changes.sh as root on iridium.

Then i checked /var/log/exim4/mainlog and i could see a mail has been sent out to aklapper@.

@Aklapper I made the script send a mail to me as well. There is data in it, just the formatting could still be improved it seems.

Should i just paste the entire thing here on the ticket?

# Puppet Name: collect_exim_stats_via_gmetric
* * * * * /usr/local/bin/exim-to-gmetric
# Puppet Name: phabstatscron_communitymetrics
0 0 1 * * /usr/local/bin/community_metrics.sh
# Puppet Name: phab_dump
10 4 * * * rsync -zpt --bwlimit=40000 -4 /srv/dumps/phabricator_public.dump dataset1001.wikimedia.org::other_misc/ >/dev/null 2>&1
# Puppet Name: phabstatscron_projectchanges
0 0 1,8,15,22,29 * * /usr/local/bin/project_changes.sh

Yay. Works. No linebreaks but who needs them anyway. Life is a stream.

dzahn, jcrespo: Thanks a lot for your help!

Change 235848 had a related patch set uploaded (by Dzahn):
phabricator: fix output formatting in metrics script

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

Change 235848 merged by Dzahn:
phabricator: fix output formatting in metrics script

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

No linebreaks but who needs them anyway. Life is a stream.

fixed with https://gerrit.wikimedia.org/r/#/c/235848/1