|
@@ -51,7 +51,7 @@ 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)
|
|
@@ -59,7 +59,7 @@ class UpgradeProgress extends Command
|
|
|
->select('book_id','paragraph','channel_uid')
|
|
->select('book_id','paragraph','channel_uid')
|
|
|
->cursor();
|
|
->cursor();
|
|
|
}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')
|
|
@@ -67,27 +67,27 @@ class UpgradeProgress extends Command
|
|
|
->cursor();
|
|
->cursor();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $this->info('channels:',count($channels));
|
|
|
|
|
|
|
+ $this->info('sentences:',count($sentences));
|
|
|
#第二步 更新段落表
|
|
#第二步 更新段落表
|
|
|
- $bar = $this->output->createProgressBar(count($channels));
|
|
|
|
|
- foreach ($channels as $channel) {
|
|
|
|
|
|
|
+ $bar = $this->output->createProgressBar(count($sentences));
|
|
|
|
|
+ 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(
|
|
|
|
|
- [
|
|
|
|
|
|
|
+ $paraInfo = [
|
|
|
'book'=>$channel->book_id,
|
|
'book'=>$channel->book_id,
|
|
|
'para'=>$channel->paragraph,
|
|
'para'=>$channel->paragraph,
|
|
|
'channel_id'=>$channel->channel_uid
|
|
'channel_id'=>$channel->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();
|
|
|
}
|
|
}
|