mirror of
				https://github.com/v2board/v2board.git
				synced 2025-11-04 19:31:45 +08:00 
			
		
		
		
	update: stat service
This commit is contained in:
		@@ -14,7 +14,7 @@ DB_USERNAME=root
 | 
			
		||||
DB_PASSWORD=123456
 | 
			
		||||
 | 
			
		||||
BROADCAST_DRIVER=log
 | 
			
		||||
CACHE_DRIVER=file
 | 
			
		||||
CACHE_DRIVER=redis
 | 
			
		||||
QUEUE_CONNECTION=redis
 | 
			
		||||
SESSION_DRIVER=redis
 | 
			
		||||
SESSION_LIFETIME=120
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ class StatisticalService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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) ?? [];
 | 
			
		||||
        if (!is_array($this->serverStats)) {
 | 
			
		||||
            $this->serverStats = [];
 | 
			
		||||
@@ -38,7 +38,7 @@ class StatisticalService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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) ?? [];
 | 
			
		||||
        if (!is_array($this->userStats)) {
 | 
			
		||||
            $this->userStats = [];
 | 
			
		||||
@@ -95,7 +95,7 @@ class StatisticalService {
 | 
			
		||||
        } else {
 | 
			
		||||
            $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)
 | 
			
		||||
@@ -107,7 +107,7 @@ class StatisticalService {
 | 
			
		||||
        } else {
 | 
			
		||||
            $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
 | 
			
		||||
@@ -165,12 +165,12 @@ class StatisticalService {
 | 
			
		||||
 | 
			
		||||
    public function clearStatUser()
 | 
			
		||||
    {
 | 
			
		||||
        Cache::forget("stat_user_{$this->startAt}");
 | 
			
		||||
        Cache::store('file')->forget("stat_user_{$this->startAt}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function clearStatServer()
 | 
			
		||||
    {
 | 
			
		||||
        Cache::forget("stat_server_{$this->startAt}");
 | 
			
		||||
        Cache::store('file')->forget("stat_server_{$this->startAt}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getStatRecord($type)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user