From 554c1730a3841696fe1fadbb8b4db439b7c65239 Mon Sep 17 00:00:00 2001 From: nk Date: Wed, 3 Jun 2026 14:49:25 +0300 Subject: [PATCH] =?UTF-8?q?perf(enrich):=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BB?= =?UTF-8?q?=D0=BB=D0=B5=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=BE=D1=87=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B8=20(3=20=D1=82=D1=80=D0=B5=D0=BA=D0=B0)=20?= =?UTF-8?q?=E2=80=94=20=D0=B1=D1=8B=D1=81=D1=82=D1=80=D0=B5=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B6=D0=B8?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D0=BD=D0=B0=D0=B1=D0=BE=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- src/enrich/enrichment.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 {