fix: dont pad numbers in redis key dates

This commit is contained in:
2023-08-17 21:31:52 +02:00
parent ed3aed85ad
commit 2f9f2d81bf
6 changed files with 83 additions and 89 deletions

4
lib/cache/logs.ts vendored
View File

@ -19,8 +19,8 @@ export type Log = {
export async function getLogs() {
const d = new Date();
const year = d.getFullYear();
const month = d.getMonth().toString().padStart(2, "0");
const day = d.getDate().toString().padStart(2, "0");
const month = d.getMonth().toString();
const day = d.getDate().toString();
const keys = await cache.keys(
`log:${year}:${month}:${day}:*`,

View File

@ -36,13 +36,15 @@ export const savePerformance = (url: string, milliseconds: number) => {
export async function getPerformances(): Promise<PerformanceRes> {
const d = new Date();
const year = d.getFullYear();
const month = d.getMonth().toString().padStart(2, "0");
const day = d.getDay().toString().padStart(2, "0");
const month = d.getMonth().toString();
const day = d.getDay().toString();
const keys = await cache.keys(
`performance:${year}:${month}:${day}:*`,
);
console.log(`performance:${year}:${month}:${day}:*`);
const performances = await Promise.all(
keys.map(async (key) =>
JSON.parse(await cache.get<string>(key)) as PerformancePoint