From 17c111a8f9c4d6d4019d9c994441bf32f628db7c Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 17 Jul 2026 02:52:30 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20multi().exec()=20=D9=82=D8=AF=20=D9=8A?= =?UTF-8?q?=D8=B1=D8=AC=D8=B9=20null=20=D9=81=D9=84=D8=A7=20=D9=8A=D9=8F?= =?UTF-8?q?=D9=81=D9=83=D9=8E=D9=91=D9=83=20=D9=85=D8=A8=D8=A7=D8=B4=D8=B1?= =?UTF-8?q?=D8=A9=20(TS2488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit كسر بناء السيرفر. ioredis يعرّف exec() كـ [error, result][] | null، فتفكيكه إلى [sumRes, countRes] خطأ نوع. صار يُقرأ بالفهرسة مع ??. Co-Authored-By: Claude Opus 4.8 --- backend/src/modules/ratings/rating-aggregate.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/modules/ratings/rating-aggregate.service.ts b/backend/src/modules/ratings/rating-aggregate.service.ts index a4a41d9..48e49d1 100644 --- a/backend/src/modules/ratings/rating-aggregate.service.ts +++ b/backend/src/modules/ratings/rating-aggregate.service.ts @@ -55,15 +55,16 @@ export class RatingAggregateService { const k = this.key(tenantId, target, targetId); await this.seed(tenantId, target, targetId, k); - const [sumRes, countRes] = await this.redis + // exec() قد يرجع null (انقطاع/إجهاض المعاملة) — لذلك لا نفكّكه مباشرة. + const res = await this.redis .multi() .hincrbyfloat(k, 'sum', stars) .hincrby(k, 'count', 1) .expire(k, AGG_TTL_SEC) .exec(); - const sum = Number(sumRes?.[1] ?? 0); - const count = Number(countRes?.[1] ?? 0); + const sum = Number(res?.[0]?.[1] ?? 0); + const count = Number(res?.[1]?.[1] ?? 0); const avg = count > 0 ? sum / count : 0; return { avg, count, shouldFlush: await this.claimDailyFlush(k) };