<td>Index size</td>
<td style="text-align: right">{{esStatus.size_human}}</td>
</tr>
+
<tr>
<td rowspan="3">Gearman</td>
<td>Open tasks</td>
<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>
return $stmt->fetchObject();
}
+ /**
+ * 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.
$queue = new Queue();
$gearStatus = $queue->getServerStatus();
+$subDb = new Subscriptions();
+$subCount = $subDb->count();
+
/**
* @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
*/
array(
'esStatus' => $esStatus,
'gearStatus' => $gearStatus,
+ 'subCount' => $subCount,
+ 'subSum' => array_sum($subCount),
)
);
?>