This commit is contained in:
2025-06-08 18:14:14 +09:00
parent 2a7ebfe639
commit efa9683cd3
2 changed files with 10 additions and 31 deletions

View File

@ -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<void> {
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;
}