作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !522
@@ -54,14 +54,10 @@ class HtmlCollect extends Command @@ -54,14 +54,10 @@ class HtmlCollect extends Command
54 protected function start_collect() 54 protected function start_collect()
55 { 55 {
56 $task_id = $this->get_task(); 56 $task_id = $this->get_task();
57 - if ($task_id === false) { 57 + if (!$task_id) {
58 //所有项目采集完成 58 //所有项目采集完成
59 sleep(60); 59 sleep(60);
60 return true; 60 return true;
61 - } elseif ($task_id === 0) {  
62 - //当前项目采集完成  
63 - sleep(2);  
64 - return true;  
65 } 61 }
66 62
67 $task_arr = explode('_', $task_id); 63 $task_arr = explode('_', $task_id);
@@ -146,12 +142,12 @@ class HtmlCollect extends Command @@ -146,12 +142,12 @@ class HtmlCollect extends Command
146 return $task_id; 142 return $task_id;
147 } 143 }
148 144
149 -  
150 - $update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->first();  
151 - if (!$update_log) { 145 + $update_log_list = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->limit(20)->get();
  146 + if ($update_log_list->count() == 0) {
152 return false; 147 return false;
153 } 148 }
154 149
  150 + foreach ($update_log_list as $update_log) {
155 switch ($update_log->api_type) { 151 switch ($update_log->api_type) {
156 case 'page': 152 case 'page':
157 $source = RouteMap::SOURCE_PAGE; 153 $source = RouteMap::SOURCE_PAGE;
@@ -174,7 +170,7 @@ class HtmlCollect extends Command @@ -174,7 +170,7 @@ class HtmlCollect extends Command
174 //设置数据库 170 //设置数据库
175 $project = ProjectServer::useProject($update_log->project_id); 171 $project = ProjectServer::useProject($update_log->project_id);
176 if ($project) { 172 if ($project) {
177 - $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(); 173 + $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();
178 174
179 if ($collect_list->count() == 0) { 175 if ($collect_list->count() == 0) {
180 $complete = true; 176 $complete = true;
@@ -190,7 +186,7 @@ class HtmlCollect extends Command @@ -190,7 +186,7 @@ class HtmlCollect extends Command
190 if ($complete) { 186 if ($complete) {
191 $update_log->collect_status = UpdateLog::COLLECT_STATUS_MAIN; 187 $update_log->collect_status = UpdateLog::COLLECT_STATUS_MAIN;
192 $update_log->save(); 188 $update_log->save();
193 - return 0; 189 + }
194 } 190 }
195 191
196 $task_id = Redis::rpop($key); 192 $task_id = Redis::rpop($key);