mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update: stat service
This commit is contained in:
parent
b39299be23
commit
948177f22e
@ -14,7 +14,7 @@ DB_USERNAME=root
|
|||||||
DB_PASSWORD=123456
|
DB_PASSWORD=123456
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=redis
|
||||||
QUEUE_CONNECTION=redis
|
QUEUE_CONNECTION=redis
|
||||||
SESSION_DRIVER=redis
|
SESSION_DRIVER=redis
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
|
@ -30,7 +30,7 @@ class StatisticalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setServerStats() {
|
public function setServerStats() {
|
||||||
$this->serverStats = Cache::get("stat_server_{$this->startAt}");
|
$this->serverStats = Cache::store('file')->get("stat_server_{$this->startAt}");
|
||||||
$this->serverStats = json_decode($this->serverStats, true) ?? [];
|
$this->serverStats = json_decode($this->serverStats, true) ?? [];
|
||||||
if (!is_array($this->serverStats)) {
|
if (!is_array($this->serverStats)) {
|
||||||
$this->serverStats = [];
|
$this->serverStats = [];
|
||||||
@ -38,7 +38,7 @@ class StatisticalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setUserStats() {
|
public function setUserStats() {
|
||||||
$this->userStats = Cache::get("stat_user_{$this->startAt}");
|
$this->userStats = Cache::store('file')->get("stat_user_{$this->startAt}");
|
||||||
$this->userStats = json_decode($this->userStats, true) ?? [];
|
$this->userStats = json_decode($this->userStats, true) ?? [];
|
||||||
if (!is_array($this->userStats)) {
|
if (!is_array($this->userStats)) {
|
||||||
$this->userStats = [];
|
$this->userStats = [];
|
||||||
@ -95,7 +95,7 @@ class StatisticalService {
|
|||||||
} else {
|
} else {
|
||||||
$this->serverStats[$serverType][$serverId] = [$u, $d];
|
$this->serverStats[$serverType][$serverId] = [$u, $d];
|
||||||
}
|
}
|
||||||
Cache::set("stat_server_{$this->startAt}", json_encode($this->serverStats));
|
Cache::store('file')->set("stat_server_{$this->startAt}", json_encode($this->serverStats));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function statUser($rate, $userId, $u, $d)
|
public function statUser($rate, $userId, $u, $d)
|
||||||
@ -107,7 +107,7 @@ class StatisticalService {
|
|||||||
} else {
|
} else {
|
||||||
$this->userStats[$rate][$userId] = [$u, $d];
|
$this->userStats[$rate][$userId] = [$u, $d];
|
||||||
}
|
}
|
||||||
Cache::set("stat_user_{$this->startAt}", json_encode($this->userStats));
|
Cache::store('file')->set("stat_user_{$this->startAt}", json_encode($this->userStats));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatUserByUserID($userId): array
|
public function getStatUserByUserID($userId): array
|
||||||
@ -165,12 +165,12 @@ class StatisticalService {
|
|||||||
|
|
||||||
public function clearStatUser()
|
public function clearStatUser()
|
||||||
{
|
{
|
||||||
Cache::forget("stat_user_{$this->startAt}");
|
Cache::store('file')->forget("stat_user_{$this->startAt}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearStatServer()
|
public function clearStatServer()
|
||||||
{
|
{
|
||||||
Cache::forget("stat_server_{$this->startAt}");
|
Cache::store('file')->forget("stat_server_{$this->startAt}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatRecord($type)
|
public function getStatRecord($type)
|
||||||
|
Loading…
Reference in New Issue
Block a user