feat: admin log page

This commit is contained in:
2025-01-25 00:00:04 +01:00
parent 979627ca2a
commit 00e7820462
8 changed files with 73 additions and 15 deletions

View File

@ -48,7 +48,7 @@ export function createCache<T>(
}
},
info(): { count: number; sizeInKB: number } {
info() {
// Cleanup expired entries before calculating info
this.cleanup();
@ -65,8 +65,8 @@ export function createCache<T>(
totalBytes += keySize + valueSize;
}
const sizeInKB = totalBytes / 1024; // Convert bytes to kilobytes
return { count, sizeInKB };
const sizeInKB = Math.floor(totalBytes / 1024); // Convert bytes to kilobytes
return { name: cacheName, count, sizeInKB };
},
has(key: string): boolean {
@ -98,3 +98,7 @@ export function createCache<T>(
});
return api;
}
export function getCacheInfo() {
return caches.values().map((c) => c.info());
}

View File

@ -172,3 +172,4 @@ export function getTextOfChild(child: DocumentChild): string | undefined {
}
return;
}

View File

@ -3,7 +3,7 @@ import { zodResponseFormat } from "https://deno.land/x/openai@v4.69.0/helpers/zo
import { OPENAI_API_KEY } from "@lib/env.ts";
import { hashString } from "@lib/helpers.ts";
import { createCache } from "@lib/cache.ts";
import recipeSchema, { recipeResponseSchema } from "@lib/recipeSchema.ts";
import { recipeResponseSchema } from "@lib/recipeSchema.ts";
const openAI = OPENAI_API_KEY && new OpenAI({ apiKey: OPENAI_API_KEY });

View File

@ -13,6 +13,15 @@ export function safeFileName(inputString: string): string {
return fileName;
}
export function toUrlSafeString(input: string): string {
return input
.trim() // Remove leading and trailing whitespace
.toLowerCase() // Convert to lowercase
.replace(/[^a-z0-9\s-]/g, "") // Remove non-alphanumeric characters except spaces and hyphens
.replace(/\s+/g, "-") // Replace spaces with hyphens
.replace(/-+/g, "-"); // Remove consecutive hyphens
}
export function extractHashTags(inputString: string) {
const hashtags = [];