Bringing the useful queries here...

>>! In T28#793720, @Aklapper wrote:
> I'm not patient enough to read API references for Conduit to find out if I can do what I want, so I played with SQL. 
> Below queries are on the "phabricator_maniphest" database and //obviously need a second pair of eyes//.
> 
>> Volume of tasks created in last month
> SELECT COUNT(*) FROM maniphest_task WHERE FROM_UNIXTIME(dateCreated,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');
> 
>> Volume of tasks closed in last month
> 
> SELECT COUNT(DISTINCT objectPHID) FROM maniphest_transaction WHERE (transactionType="mergedinto" OR (transactionType="status" AND (oldValue="\"open\"" OR oldValue="\"stalled\"") AND (newValue="\"resolved\"" OR newValue="\"invalid\"" OR newValue="\"declined\""))) AND FROM_UNIXTIME(dateCreated,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');
> 
> //Not sure about this one - need to make objectPHID value describing the task ID to be distinct because otherwise every status editwarring counts but not sure if DISTINCT picks the first or the last entry? Other option is to compare with "maniphest_task.phid" and "maniphest_task.status" but that one has a "duplicate" status while in "maniphest_transaction.transactionType" that's not a status, see query above.)//
> 
>> Volume of tasks open in total
> 
> SELECT COUNT(*) FROM maniphest_task WHERE (status = "open" OR status = "stalled");
> 
>> Volume of contributors (any activity) in last month
> 
> SELECT COUNT(DISTINCT authorPHID) FROM maniphest_transaction WHERE FROM_UNIXTIME(dateCreated,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');
> 
>> Volume of authors in last month
> 
> SELECT COUNT(DISTINCT authorPHID) FROM maniphest_task WHERE FROM_UNIXTIME(dateCreated,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');
> 
>> Volume of resolvers in last month
> 
> SELECT COUNT(DISTINCT authorPHID) FROM maniphest_transaction WHERE (transactionType="mergedinto" OR (transactionType="status" AND (oldValue="\"open\"" OR oldValue="\"stalled\"") AND (newValue="\"resolved\"" OR newValue="\"invalid\"" OR newValue="\"declined\""))) AND FROM_UNIXTIME(dateCreated,'%Y%m')=date_format(NOW() - INTERVAL 1 MONTH,'%Y%m');
> 
> //Same problem with this query as above for closed tasks.//
> 
>> Median age of open tasks by priority (excluding Needs Volunteer)
> 
> SELECT x.dateCreated from maniphest_task x, maniphest_task y WHERE (x.priority = "80" AND x.status = "open") GROUP BY x.dateCreated HAVING SUM(SIGN(1-SIGN(CAST(y.dateCreated AS SIGNED)-CAST(x.dateCreated AS SIGNED))))/COUNT(*) > .5 LIMIT 1;
> 
> //Output is a unix epoch of the average *ticket creation time* for that prio so still need to do the math to subtract from today's timestamp and convert to days. x.priority values are: 100=UnbreakNow, 80 = High; 50 = Normal; 90 = NeedsTriage; 25 = Low; 10 = NeedsVolunteer/Lowest. And those two casts in the query are needed to [[ http://dev.mysql.com/doc/refman/5.5/en/out-of-range-and-overflow.html | avoid an overflow ]], at least on my machine.//
> 
> Wondering if a dirty monthly script [[ http://git.wikimedia.org/blob/operations%2Fpuppet.git/7cc72ccf87ff2da41009f47727b8461771011634/modules%2Fbugzilla%2Ftemplates%2Fscripts%2Fbugzilla_community_metrics.sh.erb | like the one we had for Bugzilla ]] would give the Engineering Community Team at least basic insight, not expecting shiny stuff like we had on korma to appear soon?

To me this is a no brainer. That dirty monthly script was very useful, and I'm missing it already.