Aklapper has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/352125 )

Change subject: Fix "Tasks closed" SQL query in monthly Phab metrics report 
email
......................................................................

Fix "Tasks closed" SQL query in monthly Phab metrics report email

The query counted any closing events and ignored whether the task
got reopened again in the meantime. Now it checks for the current
status of each task and excludes tasks which have a closing event
in the transaction log but do not have a closed status.

Bug: T164297
Change-Id: Id29c1af95fe869f80154f8c762b1efd1ada66cf2
---
M modules/phabricator/templates/community_metrics.sh.erb
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/25/352125/1

diff --git a/modules/phabricator/templates/community_metrics.sh.erb 
b/modules/phabricator/templates/community_metrics.sh.erb
index abcfaf7..4e22ab6 100644
--- a/modules/phabricator/templates/community_metrics.sh.erb
+++ b/modules/phabricator/templates/community_metrics.sh.erb
@@ -63,10 +63,14 @@
 #echo "result_tasksclosed"
 result_tasksclosed=$(MYSQL_PWD=${sql_pass} /usr/bin/mysql -h $sql_host 
-u$sql_user $sql_name << END
 
-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');
+SELECT COUNT(DISTINCT objectPHID) FROM maniphest_transaction JOIN 
maniphest_task WHERE
+    (maniphest_transaction.transactionType="mergedinto" OR
+    (maniphest_transaction.transactionType="status" AND 
(maniphest_transaction.oldValue="\"open\"" OR
+    maniphest_transaction.oldValue="\"stalled\"") AND 
(maniphest_transaction.newValue="\"resolved\"" OR
+    maniphest_transaction.newValue="\"invalid\"" OR 
maniphest_transaction.newValue="\"declined\""))) AND
+    maniphest_transaction.objectPHID = maniphest_task.phid AND 
(maniphest_task.status = "resolved" OR
+    maniphest_task.status = "invalid" OR maniphest_task.status = "declined") 
AND
+    FROM_UNIXTIME(maniphest_transaction.dateCreated,'%Y%m')=date_format(NOW() 
- INTERVAL 1 MONTH,'%Y%m');
 
 END
 )

-- 
To view, visit https://gerrit.wikimedia.org/r/352125
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id29c1af95fe869f80154f8c762b1efd1ada66cf2
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Aklapper <aklap...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to