IndexedPages.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\RankData;
use Illuminate\Support\Facades\Log;
/**
* Class IndexedPages
* @package App\Console\Commands
* @author zbj
* @date 2023/5/11
*/
class IndexedPages extends BaseCommands
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rank_data_indexed_pages';
/**
* The console command description.
*
* @var string
*/
protected $description = '排名数据-页面收录数';
/**
* @throws \Exception
* @author zbj
* @date 2023/5/11
*/
public function do(){
$api = new QuanqiusouApi();
$site_res = $api->getSiteRes();
if (!$site_res) {
Log::channel('rank_data')->error('谷歌收录数据获取失败');
}else{
foreach ($site_res as $api_no => $num){
$project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id');
//特殊项目
if($api_no == 11201){
$project_ids[] = 2104;
}
foreach ($project_ids as $project_id){
$rank_data = RankData::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', '')->first();
if($rank_data){
$rank_data->indexed_pages_num = $num;
$rank_data->save();
}
}
}
}
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
Log::channel('rank_data')->info('开始-页面收录数据-'.count($list));
$list[2104] = 11201;
foreach ($list as $project_id => $api_no) {
Log::channel('rank_data')->info('开始-页面收录数据-' . $project_id . '->' .$api_no);
$rankDataLogic = new RankDataLogic();
$rankDataLogic->syncIndexedPages($api_no, true);
}
return true;
}
}