feat: geçmiş arşiv dolumu + arşiv sayacı
- scheduler: arşiv eşiğin altındaysa geniş geçmiş dolumu (180 gün/1500 kayıt), doluysa artımlı günlük tarama; ilk tur 90 sn sonra - LiveStatsBar: 'Sonuç Arşivi' sayacı (kazanan firma kayıt sayısı) - KİK: HTML entity çözümü tamamlandı
This commit is contained in:
+24
-5
@@ -12,20 +12,39 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { historyStats } from './history-store.mjs';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
let calisiyor = false;
|
||||
|
||||
// Arşiv boş/küçükse geniş geçmiş dolumu, doluysa artımlı günlük tarama.
|
||||
function tarataParams() {
|
||||
const s = historyStats();
|
||||
const mevcut = s.available ? (s.toplam || 0) : 0;
|
||||
const esik = Number(process.env.SCAN_BACKFILL_ESIK || 2000);
|
||||
if (mevcut < esik) {
|
||||
return {
|
||||
gun: process.env.SCAN_BACKFILL_GUN || '180',
|
||||
limit: process.env.SCAN_BACKFILL_LIMIT || '1500',
|
||||
tip: `geçmiş dolumu (arşivde ${mevcut} kayıt)`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
gun: process.env.SCAN_GUN || '3',
|
||||
limit: process.env.SCAN_LIMIT || '300',
|
||||
tip: `artımlı güncelleme (arşivde ${mevcut} kayıt)`,
|
||||
};
|
||||
}
|
||||
|
||||
function tara() {
|
||||
if (calisiyor) {
|
||||
console.log('[scheduler] önceki tarama sürüyor, bu tur atlandı');
|
||||
return;
|
||||
}
|
||||
calisiyor = true;
|
||||
const gun = process.env.SCAN_GUN || '3';
|
||||
const limit = process.env.SCAN_LIMIT || '300';
|
||||
console.log(`[scheduler] EKAP sonuç taraması başlıyor (son ${gun} gün, limit ${limit})`);
|
||||
const { gun, limit, tip } = tarataParams();
|
||||
console.log(`[scheduler] EKAP sonuç taraması — ${tip}: son ${gun} gün, limit ${limit}`);
|
||||
|
||||
const p = spawn(process.execPath, [path.join(__dirname, 'ekap-scan.mjs'), '--gun', gun, '--limit', limit], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
@@ -50,7 +69,7 @@ export function startScheduler() {
|
||||
const saat = Number(process.env.SCAN_INTERVAL_SAAT || 6);
|
||||
const ms = Math.max(1, saat) * 3600 * 1000;
|
||||
console.log(`[scheduler] geçmiş sonuç taraması her ${saat} saatte bir çalışacak`);
|
||||
// Açılıştan 2 dk sonra ilk tur (sunucu ısınsın), sonra periyodik
|
||||
setTimeout(tara, 2 * 60 * 1000).unref?.();
|
||||
// Açılıştan 90 sn sonra ilk tur (sunucu ısınsın), sonra periyodik
|
||||
setTimeout(tara, 90 * 1000).unref?.();
|
||||
setInterval(tara, ms).unref?.();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user