feat: admin log page
This commit is contained in:
10
lib/cache.ts
10
lib/cache.ts
@ -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());
|
||||
}
|
||||
|
@ -172,3 +172,4 @@ export function getTextOfChild(child: DocumentChild): string | undefined {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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 });
|
||||
|
||||
|
@ -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 = [];
|
||||
|
||||
|
Reference in New Issue
Block a user