From efa9683cd3ec5682fd13845fb31a345c503b697a Mon Sep 17 00:00:00 2001 From: Satsuki Akiba Date: Sun, 8 Jun 2025 18:14:14 +0900 Subject: [PATCH] Update --- services/batch-scheduler.ts | 35 +++++++---------------------------- services/database.ts | 6 +++--- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/services/batch-scheduler.ts b/services/batch-scheduler.ts index cbedc1c..edbdac8 100644 --- a/services/batch-scheduler.ts +++ b/services/batch-scheduler.ts @@ -25,7 +25,7 @@ class BatchScheduler { constructor() { // Check if initial run is disabled via environment variable if (config.batch.disableInitialRun) { - console.log("⏸️ Initial batch run disabled by configuration"); + console.log("⏸ Initial batch run disabled by configuration"); // Still schedule regular runs, just skip the initial one this.scheduleRegularRuns(); } else { @@ -72,7 +72,7 @@ class BatchScheduler { private async runBatch(): Promise { if (this.state.isRunning) { - console.log("⚠️ Batch process already running, skipping"); + console.log("! Batch process already running, skipping"); return; } @@ -85,28 +85,7 @@ class BatchScheduler { try { console.log("🔄 Running scheduled batch process..."); - - // Run migration for feeds without categories (only once) - if (!this.migrationCompleted) { - try { - const { migrateFeedsWithCategories, getFeedCategoryMigrationStatus } = await import("./database.js"); - const migrationStatus = await getFeedCategoryMigrationStatus(); - - if (!migrationStatus.migrationComplete) { - console.log("🔄 Running feed category migration..."); - await migrateFeedsWithCategories(); - this.migrationCompleted = true; - } else { - console.log("✅ Feed category migration already complete"); - this.migrationCompleted = true; - } - } catch (migrationError) { - console.error("❌ Error during feed category migration:", migrationError); - // Don't fail the entire batch process due to migration error - this.migrationCompleted = true; // Mark as completed to avoid retrying every batch - } - } - + await batchProcess(this.currentAbortController.signal); console.log("✅ Scheduled batch process completed"); } catch (error) { @@ -129,7 +108,7 @@ class BatchScheduler { public enable(): void { if (this.state.enabled) { - console.log("ℹ️ Batch scheduler already enabled"); + console.log("i Batch scheduler already enabled"); return; } @@ -140,12 +119,12 @@ class BatchScheduler { public disable(): void { if (!this.state.enabled) { - console.log("ℹ️ Batch scheduler already disabled"); + console.log("i Batch scheduler already disabled"); return; } this.state.enabled = false; - console.log("⏸️ Batch scheduler disabled"); + console.log("⏸ Batch scheduler disabled"); if (this.state.intervalId) { clearTimeout(this.state.intervalId); @@ -164,7 +143,7 @@ class BatchScheduler { public forceStop(): boolean { if (!this.state.isRunning || !this.currentAbortController) { - console.log("ℹ️ No batch process currently running to stop"); + console.log("i No batch process currently running to stop"); return false; } diff --git a/services/database.ts b/services/database.ts index 18f2040..2eda5a8 100644 --- a/services/database.ts +++ b/services/database.ts @@ -107,7 +107,7 @@ function extractDomain(url: string): string | null { } // Initialize database with proper error handling -async function initializeDatabase(): Promise { +function initializeDatabase(): Database { // Ensure data directory exists if (!fs.existsSync(config.paths.dataDir)) { fs.mkdirSync(config.paths.dataDir, { recursive: true }); @@ -205,7 +205,7 @@ async function initializeDatabase(): Promise { // Perform database integrity checks and fixes performDatabaseIntegrityFixes(db); - await migrateFeedsWithCategories(); + migrateFeedsWithCategories(db); return db; } @@ -1126,7 +1126,7 @@ export async function updateFeedRequestStatus( } // Migration function to classify existing feeds without categories -export async function migrateFeedsWithCategories(): Promise { +export function migrateFeedsWithCategories(db: Database): void { try { console.log("🔄 Starting feed category migration...");