作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !522
... ... @@ -54,14 +54,10 @@ class HtmlCollect extends Command
protected function start_collect()
{
$task_id = $this->get_task();
if ($task_id === false) {
if (!$task_id) {
//所有项目采集完成
sleep(60);
return true;
} elseif ($task_id === 0) {
//当前项目采集完成
sleep(2);
return true;
}
$task_arr = explode('_', $task_id);
... ... @@ -146,12 +142,12 @@ class HtmlCollect extends Command
return $task_id;
}
$update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->first();
if (!$update_log) {
$update_log_list = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->limit(20)->get();
if ($update_log_list->count() == 0) {
return false;
}
foreach ($update_log_list as $update_log) {
switch ($update_log->api_type) {
case 'page':
$source = RouteMap::SOURCE_PAGE;
... ... @@ -174,7 +170,7 @@ class HtmlCollect extends Command
//设置数据库
$project = ProjectServer::useProject($update_log->project_id);
if ($project) {
$collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '')->where('status', CollectTask::STATUS_UN)->orderBy('id', 'asc')->limit(50)->get();
$collect_list = CollectTask::select(['id', 'project_id'])->where('project_id', $update_log['project_id'])->where('source', $source)->where('language', '')->where('status', CollectTask::STATUS_UN)->orderBy('id', 'asc')->limit(100)->get();
if ($collect_list->count() == 0) {
$complete = true;
... ... @@ -190,7 +186,7 @@ class HtmlCollect extends Command
if ($complete) {
$update_log->collect_status = UpdateLog::COLLECT_STATUS_MAIN;
$update_log->save();
return 0;
}
}
$task_id = Redis::rpop($key);
... ...