浏览代码

update: statistics service

v2board 2 年之前
父节点
当前提交
ae0fd63929
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      app/Console/Commands/V2boardStatistics.php

+ 7 - 3
app/Console/Commands/V2boardStatistics.php

@@ -59,7 +59,8 @@ class V2boardStatistics extends Command
         $recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
         $recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
         $statService = new StatisticalService();
         $statService = new StatisticalService();
         $statService->setStartAt($recordAt);
         $statService->setStartAt($recordAt);
-        $stats = $statService->getStatUser();
+        $statService->setServerStats();
+        $stats = $statService->getStatServer();
         DB::beginTransaction();
         DB::beginTransaction();
         foreach ($stats as $stat) {
         foreach ($stats as $stat) {
             if (!StatServer::insert([
             if (!StatServer::insert([
@@ -86,6 +87,7 @@ class V2boardStatistics extends Command
         $recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
         $recordAt = strtotime('-1 day', strtotime(date('Y-m-d')));
         $statService = new StatisticalService();
         $statService = new StatisticalService();
         $statService->setStartAt($recordAt);
         $statService->setStartAt($recordAt);
+        $statService->setUserStats();
         $stats = $statService->getStatUser();
         $stats = $statService->getStatUser();
         DB::beginTransaction();
         DB::beginTransaction();
         foreach ($stats as $stat) {
         foreach ($stats as $stat) {
@@ -109,9 +111,11 @@ class V2boardStatistics extends Command
 
 
     private function stat()
     private function stat()
     {
     {
-        $startAt = strtotime('-1 day', strtotime(date('Y-m-d')));
+        $endAt = strtotime(date('Y-m-d'));
+        $startAt = strtotime('-1 day', $endAt);
         $statisticalService = new StatisticalService();
         $statisticalService = new StatisticalService();
-        $statisticalService->setRecordAt($startAt);
+        $statisticalService->setStartAt($startAt);
+        $statisticalService->setEndAt($endAt);
         $data = $statisticalService->generateStatData();
         $data = $statisticalService->generateStatData();
         $statistic = Stat::where('record_at', $startAt)
         $statistic = Stat::where('record_at', $startAt)
             ->where('record_type', 'd')
             ->where('record_type', 'd')