deploy: auto commit server changes 2026-06-11 20:44:36
This commit is contained in:
@@ -55,41 +55,89 @@ class KbSyncService
|
||||
]);
|
||||
}
|
||||
|
||||
public static function markArticleBackfillJobs(int $limit = 200): void
|
||||
{
|
||||
self::enqueueUnsyncedRows(
|
||||
'article',
|
||||
'article',
|
||||
'article',
|
||||
$limit,
|
||||
85,
|
||||
'COALESCE(s.update_time, s.create_time, 0)'
|
||||
);
|
||||
}
|
||||
|
||||
public static function markLotteryBackfillJobs(int $limit = 200): void
|
||||
{
|
||||
self::enqueueMissingLotteryRows('draw_result', 'lottery_draw_result', $limit);
|
||||
self::enqueueMissingLotteryRows('ai_history', 'lottery_ai_analysis', $limit);
|
||||
self::enqueueMissingLotteryRows('draw_result', 'lottery_draw_result', $limit, 80);
|
||||
self::enqueueMissingLotteryRows('ai_history', 'lottery_ai_analysis', $limit, 90);
|
||||
}
|
||||
|
||||
public static function markMatchBackfillJobs(int $limit = 200): void
|
||||
{
|
||||
self::enqueueMissingRows('match', 'event', 'match', $limit);
|
||||
self::enqueueUnsyncedRows(
|
||||
'match',
|
||||
'event',
|
||||
'match',
|
||||
$limit,
|
||||
60,
|
||||
'COALESCE(s.update_time, s.create_time, s.match_time, 0)'
|
||||
);
|
||||
}
|
||||
|
||||
private static function enqueueMissingLotteryRows(string $subtype, string $table, int $limit): void
|
||||
private static function enqueueMissingLotteryRows(string $subtype, string $table, int $limit, int $priority): void
|
||||
{
|
||||
self::enqueueMissingRows('lottery', $subtype, $table, $limit);
|
||||
self::enqueueUnsyncedRows(
|
||||
'lottery',
|
||||
$subtype,
|
||||
$table,
|
||||
$limit,
|
||||
$priority,
|
||||
'COALESCE(s.update_time, s.create_time, 0)'
|
||||
);
|
||||
}
|
||||
|
||||
private static function enqueueMissingRows(string $domain, string $subtype, string $table, int $limit): void
|
||||
{
|
||||
private static function enqueueUnsyncedRows(
|
||||
string $domain,
|
||||
string $subtype,
|
||||
string $table,
|
||||
int $limit,
|
||||
int $priority,
|
||||
string $sourceUpdatedExpr
|
||||
): void {
|
||||
try {
|
||||
$rows = Db::name($table)->alias('s')
|
||||
$query = Db::name($table)->alias('s')
|
||||
->leftJoin('ai_kb_document d', "d.domain = '{$domain}' AND d.subtype = '{$subtype}' AND d.source_id = s.id")
|
||||
->whereNull('d.id')
|
||||
->where('s.id', '>', 0)
|
||||
->whereRaw("(d.id IS NULL OR d.is_active <> 1 OR d.source_updated_at < {$sourceUpdatedExpr})");
|
||||
|
||||
self::applySourceFilters($query, $domain);
|
||||
|
||||
$rows = $query
|
||||
->order('s.id', 'desc')
|
||||
->limit($limit)
|
||||
->column('s.id');
|
||||
|
||||
foreach ($rows as $sourceId) {
|
||||
self::enqueue($domain, $subtype, (int) $sourceId, AiKbSyncJob::ACTION_UPSERT, 80);
|
||||
self::enqueue($domain, $subtype, (int) $sourceId, AiKbSyncJob::ACTION_UPSERT, $priority);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Ignore in environments where KB tables are not ready yet.
|
||||
}
|
||||
}
|
||||
|
||||
private static function applySourceFilters($query, string $domain): void
|
||||
{
|
||||
if ($domain === 'article') {
|
||||
$query->where('s.is_show', 1)->whereNull('s.delete_time');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($domain === 'match') {
|
||||
$query->where('s.is_show', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function markDocumentInactive(string $domain, string $subtype, int $sourceId): void
|
||||
{
|
||||
AiKbDocument::where([
|
||||
|
||||
Reference in New Issue
Block a user