fix(api): 修复自动墙检父节点筛选与启用语义
统一自动墙检查询逻辑,兼容 parent_id 为 null 或 0 的父节点 将 gfw_check_enabled 的空值视为开启,避免页面显示已启用却未入队 同时调整管理端自动墙检统计仅计算父节点 并更新 CI 配置以忽略 .helloagents 变更触发后端发布
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerGfwCheck;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ServerGfwCheckService
|
||||
@@ -76,9 +77,7 @@ class ServerGfwCheckService
|
||||
|
||||
public function startAutomaticChecks(?int $limit = null): array
|
||||
{
|
||||
$query = Server::query()
|
||||
->whereNull('parent_id')
|
||||
->where('gfw_check_enabled', true)
|
||||
$query = $this->whereGfwCheckEnabled($this->parentNodeQuery())
|
||||
->orderBy('sort', 'ASC')
|
||||
->orderBy('id', 'ASC');
|
||||
|
||||
@@ -158,8 +157,7 @@ class ServerGfwCheckService
|
||||
return [];
|
||||
}
|
||||
|
||||
$enabledSourceIds = Server::whereIn('id', $sourceIds)
|
||||
->where('gfw_check_enabled', true)
|
||||
$enabledSourceIds = $this->whereGfwCheckEnabled(Server::whereIn('id', $sourceIds))
|
||||
->pluck('id')
|
||||
->map(fn ($id) => (int) $id)
|
||||
->values();
|
||||
@@ -402,6 +400,23 @@ class ServerGfwCheckService
|
||||
return (bool) ($server->gfw_check_enabled ?? true);
|
||||
}
|
||||
|
||||
private function parentNodeQuery(): Builder
|
||||
{
|
||||
return Server::query()
|
||||
->where(function (Builder $query): void {
|
||||
$query->whereNull('parent_id')
|
||||
->orWhere('parent_id', 0);
|
||||
});
|
||||
}
|
||||
|
||||
private function whereGfwCheckEnabled(Builder $query): Builder
|
||||
{
|
||||
return $query->where(function (Builder $query): void {
|
||||
$query->where('gfw_check_enabled', true)
|
||||
->orWhereNull('gfw_check_enabled');
|
||||
});
|
||||
}
|
||||
|
||||
private function determineStatus(?array $operators, string $reportedStatus, string $errorMessage): string
|
||||
{
|
||||
if ($errorMessage !== '') {
|
||||
|
||||
Reference in New Issue
Block a user