[UPDATE] Added active workers to admin dashboard
* Using lower time range for shares: 120 seconds * Updated worker class with new time range for active workers * Added statistics, active users call with 120 seconds time range * Updated admin panel dashboard template Fixes #1352 once merged.
This commit is contained in:
parent
88c962266f
commit
6baad2dd06
@ -920,6 +920,24 @@ class Statistics extends Base {
|
||||
}
|
||||
return round($pps_reward / (pow(2, $this->config['target_bits']) * $dDifficulty), 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all currently active users in the past 2 minutes
|
||||
* @param interval int Time in seconds to fetch shares from
|
||||
* @return data mixed int count if any users are active, false otherwise
|
||||
**/
|
||||
public function getCountAllActiveUsers($interval=120) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(DISTINCT(SUBSTRING_INDEX( `username` , '.', 1 ))) AS total
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE our_result = 'Y'
|
||||
AND time > DATE_SUB(now(), INTERVAL ? SECOND)");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $interval) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->total);
|
||||
return $this->sqlError();
|
||||
}
|
||||
}
|
||||
|
||||
$statistics = new Statistics();
|
||||
|
||||
@ -198,19 +198,19 @@ class Worker extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all currently active workers in the past 10 minutes
|
||||
* Get all currently active workers in the past 2 minutes
|
||||
* @param none
|
||||
* @return data mixed int count if any workers are active, false otherwise
|
||||
**/
|
||||
public function getCountAllActiveWorkers() {
|
||||
public function getCountAllActiveWorkers($interval=120) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT COUNT(DISTINCT(username)) AS total
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE our_result = 'Y'
|
||||
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||
AND time > DATE_SUB(now(), INTERVAL ? SECOND)");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $interval) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->total);
|
||||
return $this->sqlError();
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ $smarty->assign('CRON_DISABLED', $cron_disabled);
|
||||
// Fetch user information
|
||||
$aUserInfo = array(
|
||||
'total' => $user->getCount(),
|
||||
'active' => $statistics->getCountAllActiveUsers(),
|
||||
'locked' => $user->getCountFiltered('is_locked', 1),
|
||||
'admins' => $user->getCountFiltered('is_admin', 1),
|
||||
'nofees' => $user->getCountFiltered('no_fees', 1)
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center">Total</th>
|
||||
<th align="center">Active</th>
|
||||
<th align="center">Locked</th>
|
||||
<th align="center">Admins</th>
|
||||
<th align="center">No Fees</th>
|
||||
@ -49,6 +50,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center">{$USER_INFO.total}</td>
|
||||
<td align="center">{$USER_INFO.active}</td>
|
||||
<td align="center">{$USER_INFO.locked}</td>
|
||||
<td align="center">{$USER_INFO.admins}</td>
|
||||
<td align="center">{$USER_INFO.nofees}</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user