diff --git a/src/enrich/enrichment.service.ts b/src/enrich/enrichment.service.ts index 2497f6e..85f5952 100644 --- a/src/enrich/enrichment.service.ts +++ b/src/enrich/enrichment.service.ts @@ -17,7 +17,8 @@ export class EnrichmentService { // Очередь обогащения с троттлингом (под лимиты Discogs/iTunes) private readonly queue: string[] = []; private running = false; - private readonly throttleMs = 1500; + private readonly throttleMs = 1000; + private readonly concurrency = 3; constructor( private readonly prisma: PrismaService, @@ -94,9 +95,8 @@ export class EnrichmentService { this.running = true; try { while (this.queue.length > 0) { - const id = this.queue.shift(); - if (!id) continue; - await this.enrichOne(id); + const batch = this.queue.splice(0, this.concurrency); + await Promise.all(batch.map((id) => this.enrichOne(id))); await this.sleep(this.throttleMs); } } finally {