diff --git a/src/enrich/enrichment.service.ts b/src/enrich/enrichment.service.ts index ffac9cd..3353ef7 100644 --- a/src/enrich/enrichment.service.ts +++ b/src/enrich/enrichment.service.ts @@ -42,18 +42,18 @@ export class EnrichmentService { void this.drain(); } - // Периодически добираем не обогащённые треки (в т.ч. накопленные ранее). - // Батч ≈ объёму, который очередь успевает прожевать за интервал при троттлинге - // ~50 запросов/мин (под лимитом Discogs 60/мин) — конвейер идёт почти непрерывно. - @Cron(CronExpression.EVERY_5_MINUTES) + // Непрерывно добираем холодный бэклог: когда очередь почти пуста — подкидываем + // батч pending (не-приоритетно, играющие треки всё равно идут вперёд). + // Раз в минуту, чтобы конвейер не простаивал между всплесками now-playing. + @Cron(CronExpression.EVERY_MINUTE) async backfill(): Promise { if (!this.discogs.enabled) return; // без токена смысла нет — не крутим вхолостую - if (this.running || this.queue.length > 0) return; // ещё жуём прошлый батч + if (this.queue.length > this.concurrency) return; // ещё есть что жевать const pending = await this.prisma.track.findMany({ where: { enrichStatus: 'pending' }, select: { id: true }, orderBy: { firstSeenAt: 'desc' }, - take: 240, + take: 100, }); for (const t of pending) this.enqueue(t.id); }