作者 刘锟

升级项目上线后也能采集增量数据

@@ -115,10 +115,25 @@ class UpdateController extends BaseController @@ -115,10 +115,25 @@ class UpdateController extends BaseController
115 $old_info->save(); 115 $old_info->save();
116 } 116 }
117 117
118 - UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news', 'website_info', 'tag'])->update(['collect_status' => 0]); 118 + $logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->get();
119 119
120 - if ($this->param['type'] == 2 && !$domain_info) {  
121 - UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->update(['status' => 0]); 120 + foreach ($logs as $log) {
  121 + if ($domain_info) {
  122 + $url_arr = parse_url($log->api_url);
  123 + $api_url = str_replace($url_arr['host'], $test_domain, $log->api_url);
  124 +
  125 + $log->api_url = $api_url;
  126 + $log->status = 0;
  127 + } else {
  128 + if ($this->param['type'] == 2) {
  129 + $log->status = 0;
  130 + }
  131 + }
  132 +
  133 + if (!in_array($log->api_type, ['website_info', 'tag'])) {
  134 + $log->collect_status = 0;
  135 + }
  136 + $log->save();
122 } 137 }
123 138
124 $this->response('采集任务添加成功'); 139 $this->response('采集任务添加成功');