作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !589
@@ -18,6 +18,7 @@ use App\Models\Channel\Channel; @@ -18,6 +18,7 @@ use App\Models\Channel\Channel;
18 use App\Models\Channel\User; 18 use App\Models\Channel\User;
19 use App\Models\Channel\Zone; 19 use App\Models\Channel\Zone;
20 use App\Models\Com\City; 20 use App\Models\Com\City;
  21 +use App\Models\Com\UpdateLog;
21 use App\Models\Devops\ServerConfig; 22 use App\Models\Devops\ServerConfig;
22 use App\Models\Domain\DomainInfo; 23 use App\Models\Domain\DomainInfo;
23 use App\Models\HomeCount\Count; 24 use App\Models\HomeCount\Count;
@@ -366,6 +367,8 @@ class ProjectController extends BaseController @@ -366,6 +367,8 @@ class ProjectController extends BaseController
366 $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); 367 $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
367 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); 368 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
368 $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]); 369 $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]);
  370 + $item['collect_time'] = $item['is_upgrade'] ? UpdateLog::getProjectUpdate($item['id']) : '';
  371 +
369 return $item; 372 return $item;
370 } 373 }
371 374
@@ -100,17 +100,7 @@ class ProjectLogic extends BaseLogic @@ -100,17 +100,7 @@ class ProjectLogic extends BaseLogic
100 $info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']); 100 $info['deploy_build']['other_project']= json_decode($info['deploy_build']['other_project']);
101 } 101 }
102 //升级项目采集完成时间 102 //升级项目采集完成时间
103 - $collect_time = '';  
104 - if($info['is_upgrade'] == 1){  
105 - $collect_un_count = UpdateLog::where('project_id',$id)->where('collect_status',0)->count();  
106 - if($collect_un_count > 0){  
107 - $collect_time = '采集中';  
108 - }else{  
109 - $collect_info = UpdateLog::where('project_id',$id)->orderBy('updated_at','desc')->first();  
110 - $collect_time = $collect_info->updated_at->format('Y-m-d H:i:s');  
111 - }  
112 - }  
113 - $info['collect_time'] = $collect_time; 103 + $info['collect_time'] = $info['is_upgrade'] ? UpdateLog::getProjectUpdate($id) : '';
114 return $this->success($info); 104 return $this->success($info);
115 } 105 }
116 106
@@ -61,4 +61,24 @@ class UpdateLog extends Model @@ -61,4 +61,24 @@ class UpdateLog extends Model
61 61
62 return true; 62 return true;
63 } 63 }
  64 +
  65 + /**
  66 + * 获取项目当前采集情况
  67 + * @param $project_id
  68 + * @return string
  69 + * @author Akun
  70 + * @date 2024/05/27 17:04
  71 + */
  72 + public static function getProjectUpdate($project_id)
  73 + {
  74 + $collect_un_count = UpdateLog::where('project_id', $project_id)->where('collect_status', 0)->count();
  75 + if ($collect_un_count > 0) {
  76 + $collect_time = '采集中';
  77 + } else {
  78 + $collect_info = UpdateLog::where('project_id', $project_id)->orderBy('updated_at', 'desc')->first();
  79 + $collect_time = $collect_info->updated_at->format('Y-m-d H:i:s');
  80 + }
  81 +
  82 + return $collect_time;
  83 + }
64 } 84 }