|
@@ -8,12 +8,13 @@ use App\Models\PaliSentence;
|
|
|
use App\Models\Progress;
|
|
use App\Models\Progress;
|
|
|
use App\Models\ProgressChapter;
|
|
use App\Models\ProgressChapter;
|
|
|
use App\Models\PaliText;
|
|
use App\Models\PaliText;
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class UpgradeProgress extends Command
|
|
class UpgradeProgress extends Command
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
* The name and signature of the console command.
|
|
* The name and signature of the console command.
|
|
|
- * php artisan upgrade:progress --book=122 --para=244 --channel=5310999c-0b0c-4bb0-9bb9-9cdd176e9ef0
|
|
|
|
|
|
|
+ * php artisan upgrade:progress --book=168 --para=916 --channel=19f53a65-81db-4b7d-8144-ac33f1217d34
|
|
|
* @var string
|
|
* @var string
|
|
|
*/
|
|
*/
|
|
|
protected $signature = 'upgrade:progress {--book=} {--para=} {--channel=}';
|
|
protected $signature = 'upgrade:progress {--book=} {--para=} {--channel=}';
|
|
@@ -51,43 +52,42 @@ class UpgradeProgress extends Command
|
|
|
$para = $this->option('para');
|
|
$para = $this->option('para');
|
|
|
$channelId = $this->option('channel');
|
|
$channelId = $this->option('channel');
|
|
|
if($book && $para && $channelId){
|
|
if($book && $para && $channelId){
|
|
|
- $channels = Sentence::where('strlen','>',0)
|
|
|
|
|
|
|
+ $sentences = Sentence::where('strlen','>',0)
|
|
|
->where('book_id',$book)
|
|
->where('book_id',$book)
|
|
|
->where('paragraph',$para)
|
|
->where('paragraph',$para)
|
|
|
->where('channel_uid',$channelId)
|
|
->where('channel_uid',$channelId)
|
|
|
->groupby('book_id','paragraph','channel_uid')
|
|
->groupby('book_id','paragraph','channel_uid')
|
|
|
- ->select('book_id','paragraph','channel_uid')
|
|
|
|
|
- ->cursor();
|
|
|
|
|
|
|
+ ->select('book_id','paragraph','channel_uid');
|
|
|
}else{
|
|
}else{
|
|
|
- $channels = Sentence::where('strlen','>',0)
|
|
|
|
|
|
|
+ $sentences = Sentence::where('strlen','>',0)
|
|
|
->where('book_id','<',1000)
|
|
->where('book_id','<',1000)
|
|
|
->where('channel_uid','<>','')
|
|
->where('channel_uid','<>','')
|
|
|
->groupby('book_id','paragraph','channel_uid')
|
|
->groupby('book_id','paragraph','channel_uid')
|
|
|
- ->select('book_id','paragraph','channel_uid')
|
|
|
|
|
- ->cursor();
|
|
|
|
|
|
|
+ ->select('book_id','paragraph','channel_uid');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $this->info('channels:',count($channels));
|
|
|
|
|
|
|
+ $count = $sentences->count();
|
|
|
|
|
+ $sentences = $sentences->cursor();
|
|
|
|
|
+ $this->info('sentences:'.$count);
|
|
|
#第二步 更新段落表
|
|
#第二步 更新段落表
|
|
|
- $bar = $this->output->createProgressBar(count($channels));
|
|
|
|
|
- foreach ($channels as $channel) {
|
|
|
|
|
|
|
+ $bar = $this->output->createProgressBar($count);
|
|
|
|
|
+ foreach ($sentences as $sentence) {
|
|
|
# 第二步 生成para progress 1,2,15,zh-tw
|
|
# 第二步 生成para progress 1,2,15,zh-tw
|
|
|
# 计算此段落完成时间
|
|
# 计算此段落完成时间
|
|
|
$finalAt = Sentence::where('strlen','>',0)
|
|
$finalAt = Sentence::where('strlen','>',0)
|
|
|
- ->where('book_id',$channel->book_id)
|
|
|
|
|
- ->where('paragraph',$channel->paragraph)
|
|
|
|
|
- ->where('channel_uid',$channel->channel_uid)
|
|
|
|
|
|
|
+ ->where('book_id',$sentence->book_id)
|
|
|
|
|
+ ->where('paragraph',$sentence->paragraph)
|
|
|
|
|
+ ->where('channel_uid',$sentence->channel_uid)
|
|
|
->max('created_at');
|
|
->max('created_at');
|
|
|
$updateAt = Sentence::where('strlen','>',0)
|
|
$updateAt = Sentence::where('strlen','>',0)
|
|
|
- ->where('book_id',$channel->book_id)
|
|
|
|
|
- ->where('paragraph',$channel->paragraph)
|
|
|
|
|
- ->where('channel_uid',$channel->channel_uid)
|
|
|
|
|
|
|
+ ->where('book_id',$sentence->book_id)
|
|
|
|
|
+ ->where('paragraph',$sentence->paragraph)
|
|
|
|
|
+ ->where('channel_uid',$sentence->channel_uid)
|
|
|
->max('updated_at');
|
|
->max('updated_at');
|
|
|
# 查询每个段落的等效巴利语字符数
|
|
# 查询每个段落的等效巴利语字符数
|
|
|
$result_sent = Sentence::where('strlen','>',0)
|
|
$result_sent = Sentence::where('strlen','>',0)
|
|
|
- ->where('book_id',$channel->book_id)
|
|
|
|
|
- ->where('paragraph',$channel->paragraph)
|
|
|
|
|
- ->where('channel_uid',$channel->channel_uid)
|
|
|
|
|
|
|
+ ->where('book_id',$sentence->book_id)
|
|
|
|
|
+ ->where('paragraph',$sentence->paragraph)
|
|
|
|
|
+ ->where('channel_uid',$sentence->channel_uid)
|
|
|
->select('word_start')
|
|
->select('word_start')
|
|
|
->get();
|
|
->get();
|
|
|
if (count($result_sent) > 0) {
|
|
if (count($result_sent) > 0) {
|
|
@@ -95,25 +95,25 @@ class UpgradeProgress extends Command
|
|
|
$para_strlen = 0;
|
|
$para_strlen = 0;
|
|
|
foreach ($result_sent as $sent) {
|
|
foreach ($result_sent as $sent) {
|
|
|
# code...
|
|
# code...
|
|
|
- $para_strlen += PaliSentence::where('book',$channel->book_id)
|
|
|
|
|
- ->where('paragraph',$channel->paragraph)
|
|
|
|
|
|
|
+ $para_strlen += PaliSentence::where('book',$sentence->book_id)
|
|
|
|
|
+ ->where('paragraph',$sentence->paragraph)
|
|
|
->where('word_begin',$sent->word_start)
|
|
->where('word_begin',$sent->word_start)
|
|
|
->value('length');
|
|
->value('length');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- Progress::updateOrInsert(
|
|
|
|
|
- [
|
|
|
|
|
- 'book'=>$channel->book_id,
|
|
|
|
|
- 'para'=>$channel->paragraph,
|
|
|
|
|
- 'channel_id'=>$channel->channel_uid
|
|
|
|
|
- ],
|
|
|
|
|
- [
|
|
|
|
|
|
|
+ $paraInfo = [
|
|
|
|
|
+ 'book'=>$sentence->book_id,
|
|
|
|
|
+ 'para'=>$sentence->paragraph,
|
|
|
|
|
+ 'channel_id'=>$sentence->channel_uid
|
|
|
|
|
+ ];
|
|
|
|
|
+ $paraData = [
|
|
|
'lang'=>'en',
|
|
'lang'=>'en',
|
|
|
'all_strlen'=>$para_strlen,
|
|
'all_strlen'=>$para_strlen,
|
|
|
'public_strlen'=>$para_strlen,
|
|
'public_strlen'=>$para_strlen,
|
|
|
'created_at'=>$finalAt,
|
|
'created_at'=>$finalAt,
|
|
|
'updated_at'=>$updateAt,
|
|
'updated_at'=>$updateAt,
|
|
|
- ]);
|
|
|
|
|
|
|
+ ];
|
|
|
|
|
+ Log::debug('Progress updateOrInsert',['para'=>$paraInfo,'data'=>$paraData]);
|
|
|
|
|
+ Progress::updateOrInsert($paraInfo,$paraData);
|
|
|
}
|
|
}
|
|
|
$bar->advance();
|
|
$bar->advance();
|
|
|
}
|
|
}
|