2
0
Эх сурвалжийг харах

Merge pull request #1165 from visuddhinanda/laravel

nissaya 统计
visuddhinanda 2 жил өмнө
parent
commit
63c1d102d2

+ 31 - 36
app/Console/Commands/StatisticsNissaya.php

@@ -6,6 +6,7 @@ use Illuminate\Console\Command;
 use App\Models\Channel;
 use App\Models\Channel;
 use App\Models\Sentence;
 use App\Models\Sentence;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Storage;
+use Carbon\Carbon;
 
 
 class StatisticsNissaya extends Command
 class StatisticsNissaya extends Command
 {
 {
@@ -21,7 +22,7 @@ class StatisticsNissaya extends Command
      *
      *
      * @var string
      * @var string
      */
      */
-    protected $description = '统计nissaya 每录入进度';
+    protected $description = '统计nissaya 每录入进度';
 
 
     /**
     /**
      * Create a new command instance.
      * Create a new command instance.
@@ -41,45 +42,39 @@ class StatisticsNissaya extends Command
     public function handle()
     public function handle()
     {
     {
         $nissaya_channel = Channel::where('type','nissaya')->select('uid')->get();
         $nissaya_channel = Channel::where('type','nissaya')->select('uid')->get();
-        $channels = [];
-        foreach ($nissaya_channel as $key => $value) {
-            # code...
-            $channels[] = $value->uid;
-        }
-        $this->info('channel:'.count($channels));
+        $this->info('channel:'.count($nissaya_channel));
         $maxDay = 360;
         $maxDay = 360;
-        $file = "public/export/nissaya-daily.csv";
+        $file = "public/statistics/nissaya-monthly.csv";
         Storage::disk('local')->put($file, "");
         Storage::disk('local')->put($file, "");
-        #按天获取数据
-        for($i = 1; $i <= $maxDay; $i++){
-            $day = strtotime("today -{$i} day");
-            $date = date("Y-m-d",$day);
-            $strlen = Sentence::whereIn('channel_uid',$channels)
-                    ->whereDate('created_at','=',$date)
-                    ->sum('strlen');
-            $editor = Sentence::whereIn('channel_uid',$channels)
-                    ->whereDate('created_at','=',$date)
-                    ->groupBy('editor_uid')
-                    ->select('editor_uid')->get();
-            $info = $date.','.$strlen.','.count($editor);
-            $this->info($info);
-            Storage::disk('local')->append($file, $info);
-        }
-        $file = "public/export/nissaya-week.csv";
-        Storage::disk('local')->put($file, "");
-        for($i = 1; $i <= $maxDay; $i=$i+7){
-            $day1 = strtotime("today -{$i} day");
-            $date1 = date("Y-m-d",$day1);
-            $j = $i - 7;
-            $date2 = date("Y-m-d",strtotime("today -{$j} day"));
-            $editor = Sentence::whereIn('channel_uid',$channels)
-                    ->whereDate('created_at','>',$date1)
-                    ->whereDate('created_at','<=',$date2)
-                    ->groupBy('editor_uid')
-                    ->select('editor_uid')->get();
-            $info = $date2.','.$date1.','.count($editor);
+        #按月获取数据
+        $firstDay = Sentence::whereIn('channel_uid',$nissaya_channel)
+                            ->orderBy('created_at')
+                            ->select('created_at')
+                            ->first();
+        $firstDay = strtotime($firstDay->created_at);
+        $firstMonth = Carbon::create(date("Y-m",$firstDay));
+        $now = Carbon::now();
+        $current = $firstMonth;
+        $sumStrlen = 0;
+        while ($current <= $now) {
+            # code...
+            $start = Carbon::create($current)->startOfMonth();
+            $end = Carbon::create($current)->endOfMonth();
+            $date = $current->format('Y-m');
+            $strlen = Sentence::whereIn('channel_uid',$nissaya_channel)
+                              ->whereDate('created_at','>=',$start)
+                              ->whereDate('created_at','<=',$end)
+                              ->sum('strlen');
+            $sumStrlen += $strlen;
+            $editor = Sentence::whereIn('channel_uid',$nissaya_channel)
+                              ->whereDate('created_at','>=',$start)
+                              ->whereDate('created_at','<=',$end)
+                              ->groupBy('editor_uid')
+                              ->select('editor_uid')->get();
+            $info = $date.','.$strlen.','.$sumStrlen.','.count($editor);
             $this->info($info);
             $this->info($info);
             Storage::disk('local')->append($file, $info);
             Storage::disk('local')->append($file, $info);
+            $current->addMonth(1);
         }
         }
         return 0;
         return 0;
     }
     }

+ 4 - 1
app/Console/Commands/TestMdRender.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 
 use Illuminate\Console\Command;
 use Illuminate\Console\Command;
 use App\Http\Api\MdRender;
 use App\Http\Api\MdRender;
+use Illuminate\Support\Str;
 
 
 class TestMdRender extends Command
 class TestMdRender extends Command
 {
 {
@@ -45,6 +46,8 @@ class TestMdRender extends Command
         //$markdown .= "多**行注**释\n\n";
         //$markdown .= "多**行注**释\n\n";
         //$markdown .= "多行注释\n";
         //$markdown .= "多行注释\n";
         //$markdown .= "}}\n\n";
         //$markdown .= "}}\n\n";
+        $markdown .= "## heading \n\n";
+        $markdown .= "ddd \n\n";
         $markdown .= "- title \n";
         $markdown .= "- title \n";
         $markdown .= "  \n";
         $markdown .= "  \n";
         $markdown .= "  content-1\n";
         $markdown .= "  content-1\n";
@@ -79,7 +82,7 @@ class TestMdRender extends Command
         //$html = MdRender::xmlQueryId($xml, "1");
         //$html = MdRender::xmlQueryId($xml, "1");
         //$sent = MdRender::take_sentence($html);
         //$sent = MdRender::take_sentence($html);
         //print_r($sent);
         //print_r($sent);
-
+        echo Str::markdown($markdown);
         echo MdRender::render2($markdown,'00ae2c48-c204-4082-ae79-79ba2740d506',null,'read','nissaya');
         echo MdRender::render2($markdown,'00ae2c48-c204-4082-ae79-79ba2740d506',null,'read','nissaya');
         return 0;
         return 0;
     }
     }

+ 1 - 1
app/Http/Api/MdRender.php

@@ -200,7 +200,7 @@ class MdRender{
                 $markdown = preg_replace($pattern,$replacement,$markdown);
                 $markdown = preg_replace($pattern,$replacement,$markdown);
             }
             }
         }
         }
-        $markdown = preg_replace("/\n\n/","<div></div>",$markdown);
+        //$markdown = preg_replace("/\n\n/","<div></div>",$markdown);
 
 
 
 
         /**
         /**

+ 7 - 0
public/app/calendar/history.html

@@ -131,6 +131,13 @@
 						description:
 						description:
 							"Less bothering, More Concentration",
 							"Less bothering, More Concentration",
 					},
 					},
+                    {
+                        x: Date.UTC(2022, 10, 1),
+						name: "wikipāli 2.0 开始重构",
+						label: "wikipāli 2.0 rebuild start",
+						description:
+							"Rebuild frontend and backend by popular framework.Further and user-friendly.",
+					},
 					{
 					{
 						x: Date.UTC(2023, 4, 1),
 						x: Date.UTC(2023, 4, 1),
 						name: "翻译缅语依词释nissaya",
 						name: "翻译缅语依词释nissaya",