Переглянути джерело

Merge pull request #2423 from visuddhinanda/development

Development
visuddhinanda 2 тижнів тому
батько
коміт
1e277bdfaa

+ 12 - 10
api-v13/app/Console/Commands/ExportChannel.php

@@ -47,7 +47,7 @@ class ExportChannel extends Command
         if (\App\Tools\Tools::isStop()) {
             return 0;
         }
-        Log::debug('task export offline channel-table start');
+        $this->info('task export offline channel-table start');
         $exportFile = storage_path('app/public/export/offline/' . $this->argument('db') . '-' . date("Y-m-d") . '.db3');
         $dbh = new \PDO('sqlite:' . $exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
@@ -62,10 +62,8 @@ class ExportChannel extends Command
             Log::error($e->getMessage(), ['exception' => $e]);
             return 1;
         }
-
-        $bar = $this->output->createProgressBar(Channel::where('status', 30)->count());
-        foreach (
-            Channel::where('status', 30)
+        $total = Channel::where('status', 30)->count();
+        $channels= Channel::where('status', 30)
                 ->select([
                     'uid',
                     'name',
@@ -76,8 +74,9 @@ class ExportChannel extends Command
                     'setting',
                     'created_at'
                 ])
-                ->cursor() as $row
-        ) {
+                ->cursor();
+
+        foreach ($channels as $key => $row  ) {
             $currData = array(
                 $row->uid,
                 $row->name,
@@ -89,11 +88,14 @@ class ExportChannel extends Command
                 $row->created_at,
             );
             $stmt->execute($currData);
-            $bar->advance();
+
+            if($key % 30 ===0){
+                $precent = (int)($key*100/$total);
+                $this->line("[{$precent}%]");
+            }
         }
         $dbh->commit();
-        $bar->finish();
-        Log::debug('task export offline channel-table finished');
+        $this->info('task export offline channel-table finished');
         return 0;
     }
 }

+ 3 - 5
api-v13/app/Console/Commands/ExportOffline.php

@@ -15,7 +15,7 @@ class ExportOffline extends Command
      * php artisan export:offline lzma
      * @var string
      */
-    protected $signature = 'export:offline {format?  : zip file format 7z,lzma,gz } {--shortcut}  {--driver=str}';
+    protected $signature = 'export:offline {format?  : zip file format 7z,lzma,gz } {--test}  {--driver=str}';
 
     /**
      * The console command description.
@@ -76,11 +76,10 @@ class ExportOffline extends Command
         $this->call('export:term');
 
         //导出channel
-        $this->info('export channel start');
         $this->call('export:channel', ['db' => 'wikipali-offline']);
         $this->call('export:channel', ['db' => 'wikipali-offline-index']);
 
-        if (!$this->option('shortcut')) {
+        if (!$this->option('test')) {
             //tag
             $this->info('export tag start');
             $this->call('export:tag', ['db' => 'wikipali-offline']);
@@ -100,8 +99,7 @@ class ExportOffline extends Command
             $this->call('export:sentence', ['--type' => 'original', '--driver' => $this->option('driver')]);
         }
 
-        $this->info('zip');
-        Log::info('export offline: db写入完毕 开始压缩');
+        $this->info('export offline: db写入完毕 开始压缩');
 
         sleep(5);
         $this->call('export:zip', [

+ 4 - 4
api-v13/app/Console/Commands/UpgradeAITranslation.php

@@ -146,7 +146,7 @@ class UpgradeAITranslation extends Command
         $cacheKey = self::CACHE_KEY_PREFIX.':'.$type.':'.$channelId;
 
         if ($this->option('fresh')) {
-            Cache::forget($cacheKey);
+            //Cache::forget($cacheKey);
             $this->info('Cleared cached cursor.');
         }
 
@@ -154,7 +154,7 @@ class UpgradeAITranslation extends Command
         $isFullRun = ! $this->option('book') && ! $this->option('para');
 
         // 从缓存恢复已完成的 (book, para) 集合,作为重入时的稳定游标
-        $done = Cache::get($cacheKey, []);
+        $done = [];// Cache::get($cacheKey, []);
 
         $books = [];
         if ($this->option('book')) {
@@ -209,7 +209,7 @@ class UpgradeAITranslation extends Command
                 $this->info($this->argument('type')." {$book}-{$paragraph} ".count($data).' sentences time='.$time);
                 // 该处理单元全部写库完成后再标记游标,确保中途中断不会误跳过
                 $done[$cursor] = true;
-                Cache::put($cacheKey, $done, now()->addHours(24));
+                //Cache::put($cacheKey, $done, now()->addHours(24));
             }
 
             $param = [
@@ -236,7 +236,7 @@ class UpgradeAITranslation extends Command
 
         // 完整遍历正常结束,清空断点缓存
         if ($isFullRun) {
-            Cache::forget($cacheKey);
+            //Cache::forget($cacheKey);
         }
 
         return 0;