作者 赵彬吉

update

... ... @@ -43,43 +43,50 @@ class RankData extends BaseCommands
*/
public function do()
{
try {
Log::channel('rank_data')->info('开始-排名数据');
//同步api_no
try {
$this->SyncApiNo();
}catch (\Exception $e){
} catch (\Exception $e) {
Log::channel('rank_data')->error('同步api_no失败:' . $e->getMessage());
}
//所有项目 今日是否达标 重置
//有失败会重跑任务,导致达标又被重置 加缓存一天只重置一次
if(!Cache::get('clear_remain_today_'.date('Y-m-d'))){
if (!Cache::get('clear_remain_today_' . date('Y-m-d'))) {
Project::where('is_remain_today', 1)->update(['is_remain_today' => 0]);
Cache::set('clear_remain_today_'.date('Y-m-d'), 1, 24 * 3600);
Cache::set('clear_remain_today_' . date('Y-m-d'), 1, 24 * 3600);
}
$error = 0;
$api = new QuanqiusouApi();
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>' , 0)->select('api_no','minor_languages','project_id')->get();
Log::channel('rank_data')->info('开始-排名数据-'.count($list));
$list = DeployOptimize::where('api_no', '>', 0)->select('api_no', 'minor_languages', 'project_id')->get();
Log::channel('rank_data')->info('开始-排名数据-' . count($list));
//当日所有站点谷歌收录数据
$site_res = $api->getSiteRes();
if(!$site_res){
if (!$site_res) {
return false;
}
foreach ($list as $item){
foreach ($list as $item) {
echo $item['api_no'] . PHP_EOL;
try {
(new RankDataLogic())->syncRankData($item['api_no'], $site_res);
}catch (\Exception $e){
} catch (\Exception $e) {
Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage());
$error++;
continue;
}
}
return !$error;
} catch (\Exception $e) {
Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage());
throw new \Exception($e->getMessage());
}
}
/**
... ... @@ -98,7 +105,7 @@ class RankData extends BaseCommands
$api = new QuanqiusouApi();
$ai_nos = $api->getWebApiNo();
if($ai_nos){
foreach ($deploy_optimizes as $deploy_optimize){
$domain = DomainInfo::where('id', $deploy_optimize['domain'])->value('domain');
if(!$domain){
... ... @@ -111,5 +118,6 @@ class RankData extends BaseCommands
}
}
}
}
}
... ...