]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/SQLStats/SQLStatsPlugin.php
Event upgraded to microformats2
[quix0rs-gnu-social.git] / plugins / SQLStats / SQLStatsPlugin.php
index 9e810a3ffc10fcf7b99b21071f614045e15a604b..b20f72be424cd396ad28c511acbb7a4f377846d7 100644 (file)
@@ -25,9 +25,8 @@ if (!defined('STATUSNET')) {
  * Check DB queries for filesorts and such and log em.
  *
  * @package SQLStatsPlugin
- * @maintainer Evan Prodromou <brion@status.net>
+ * @maintainer Evan Prodromou <evan@status.net>
  */
-
 class SQLStatsPlugin extends Plugin
 {
     protected $queryCount = 0;
@@ -38,10 +37,11 @@ class SQLStatsPlugin extends Plugin
     function onPluginVersion(&$versions)
     {
         $versions[] = array('name' => 'SQLStats',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou',
                             'homepage' => 'http://status.net/wiki/Plugin:SQLStats',
                             'rawdescription' =>
+                            // TRANS: Plugin decription.
                             _m('Debug tool to watch for poorly indexed DB queries.'));
 
         return true;
@@ -65,12 +65,16 @@ class SQLStatsPlugin extends Plugin
 
     function cleanup()
     {
-        $this->log(LOG_INFO, sprintf('%d queries this hit (total = %d, avg = %d, max = %d, min = %d)',
-                                     count($this->queryTimes),
-                                     array_sum($this->queryTimes),
-                                     array_sum($this->queryTimes)/count($this->queryTimes),
-                                     max($this->queryTimes),
-                                     min($this->queryTimes)));
+        if (count($this->queryTimes) == 0) {
+            $this->log(LOG_INFO, sprintf('0 queries this hit.'));
+        } else {
+            $this->log(LOG_INFO, sprintf('%d queries this hit (total = %d, avg = %d, max = %d, min = %d)',
+                                         count($this->queryTimes),
+                                         array_sum($this->queryTimes),
+                                         array_sum($this->queryTimes)/count($this->queryTimes),
+                                         max($this->queryTimes),
+                                         min($this->queryTimes)));
+        }
 
         $verbose = common_config('sqlstats', 'verbose');