mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-08 19:16:37 +08:00
type changes
This commit is contained in:
parent
35c6263560
commit
e3a6787f06
@ -74,15 +74,11 @@ export const getAvailableDateKeys = async (): Promise<string[]> => {
|
|||||||
|
|
||||||
export const getSignInCountForPeriod = async (dateKey: string): Promise<number> => {
|
export const getSignInCountForPeriod = async (dateKey: string): Promise<number> => {
|
||||||
try {
|
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<string, string>;
|
||||||
return Object.values(counts).reduce((total, count) => {
|
return Object.values(counts).reduce((total, count) => {
|
||||||
// Ensure that 'count' is a string before parsing it to an integer.
|
// Now TypeScript knows that 'count' is a string.
|
||||||
if (typeof count === 'string') {
|
return total + parseInt(count, 10);
|
||||||
return total + parseInt(count, 10);
|
|
||||||
} else {
|
|
||||||
console.error(`Count value is not a string: ${count}`);
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
}, 0);
|
}, 0);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to get sign-in count for period ${dateKey}`, error);
|
console.error(`Failed to get sign-in count for period ${dateKey}`, error);
|
||||||
@ -91,6 +87,7 @@ export const getSignInCountForPeriod = async (dateKey: string): Promise<number>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const getDetailsByUser = async (dateKey: string): Promise<Record<string, number>> => {
|
export const getDetailsByUser = async (dateKey: string): Promise<Record<string, number>> => {
|
||||||
try {
|
try {
|
||||||
const rawCounts = await redis.hgetall(`signin_count:${dateKey}`);
|
const rawCounts = await redis.hgetall(`signin_count:${dateKey}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user