aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-11-24 23:11:52 +0100
committerChristian Weiske <cweiske@cweiske.de>2016-11-24 23:11:52 +0100
commitdd3e0698a71ca2746166f006135aeace83dfeb20 (patch)
treeb7e797bad721a980dbe06301bfe089991d146c5d
parent161c1102795805ee665a727e185fb71e58c92110 (diff)
downloadphinde-dd3e0698a71ca2746166f006135aeace83dfeb20.tar.gz
phinde-dd3e0698a71ca2746166f006135aeace83dfeb20.zip
show subscriptions on status page
-rw-r--r--data/templates/status.htm13
-rw-r--r--src/phinde/Subscriptions.php22
-rw-r--r--www/status.php5
3 files changed, 40 insertions, 0 deletions
diff --git a/data/templates/status.htm b/data/templates/status.htm
index 86c39fe..fb8daf3 100644
--- a/data/templates/status.htm
+++ b/data/templates/status.htm
@@ -30,6 +30,7 @@
<td>Index size</td>
<td style="text-align: right">{{esStatus.size_human}}</td>
</tr>
+
<tr>
<td rowspan="3">Gearman</td>
<td>Open tasks</td>
@@ -43,6 +44,18 @@
<td>Task workers</td>
<td style="text-align: right">{{gearStatus.workers}}</td>
</tr>
+
+ <tr>
+ <td rowspan="{{subCount|length + 1}}">Subscriptions</td>
+ <td>Total</td>
+ <td style="text-align: right">{{subSum}}</td>
+ </tr>
+ {% for key, number in subCount %}
+ <tr>
+ <td>{{key}}</td>
+ <td style="text-align: right">{{number}}</td>
+ </tr>
+ {% endfor %}
</tbody>
</table>
diff --git a/src/phinde/Subscriptions.php b/src/phinde/Subscriptions.php
index 4d00ab8..5aac9b2 100644
--- a/src/phinde/Subscriptions.php
+++ b/src/phinde/Subscriptions.php
@@ -38,6 +38,28 @@ class Subscriptions
}
/**
+ * Count number of subscriptions
+ *
+ * @return array Array of keys with different status, number as value
+ */
+ public function count()
+ {
+ $stmt = $this->db->prepare(
+ 'SELECT COUNT(*) as count, sub_status FROM subscriptions'
+ . ' GROUP BY sub_status'
+ . ' ORDER BY sub_status'
+ );
+ $stmt->execute();
+
+ $res = [];
+ foreach ($stmt as $row) {
+ $res[$row['sub_status']] = $row['count'];
+ }
+
+ return $res;
+ }
+
+ /**
* Create a new subscription entry in database.
* Automatically generates secret, capkey and lease seconds.
*
diff --git a/www/status.php b/www/status.php
index 4118c9c..a57c121 100644
--- a/www/status.php
+++ b/www/status.php
@@ -8,6 +8,9 @@ $esStatus = $es->getIndexStatus();
$queue = new Queue();
$gearStatus = $queue->getServerStatus();
+$subDb = new Subscriptions();
+$subCount = $subDb->count();
+
/**
* @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
*/
@@ -29,6 +32,8 @@ render(
array(
'esStatus' => $esStatus,
'gearStatus' => $gearStatus,
+ 'subCount' => $subCount,
+ 'subSum' => array_sum($subCount),
)
);
?>