From e3a6787f063df91dbe0cefeba52741fc2f08f5b1 Mon Sep 17 00:00:00 2001 From: DirkSchlossmacher <62424946+DirkSchlossmacher@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:52:02 +0100 Subject: [PATCH] type changes --- app/utils/cloud/redisRestClient.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/utils/cloud/redisRestClient.ts b/app/utils/cloud/redisRestClient.ts index 267a76070..ed4addf7e 100644 --- a/app/utils/cloud/redisRestClient.ts +++ b/app/utils/cloud/redisRestClient.ts @@ -74,15 +74,11 @@ export const getAvailableDateKeys = async (): Promise => { export const getSignInCountForPeriod = async (dateKey: string): Promise => { try { - const counts = await redis.hgetall(`signin_count:${dateKey}`); + // Explicitly cast the result of redis.hgetall to an object with string values. + const counts = await redis.hgetall(`signin_count:${dateKey}`) as Record; return Object.values(counts).reduce((total, count) => { - // Ensure that 'count' is a string before parsing it to an integer. - if (typeof count === 'string') { - return total + parseInt(count, 10); - } else { - console.error(`Count value is not a string: ${count}`); - return total; - } + // Now TypeScript knows that 'count' is a string. + return total + parseInt(count, 10); }, 0); } catch (error) { console.error(`Failed to get sign-in count for period ${dateKey}`, error); @@ -91,6 +87,7 @@ export const getSignInCountForPeriod = async (dateKey: string): Promise }; + export const getDetailsByUser = async (dateKey: string): Promise> => { try { const rawCounts = await redis.hgetall(`signin_count:${dateKey}`);