Spaces:
Configuration error
Configuration error
Download src/lib/load.ts from SreejithSHR/umami: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/load.ts
- Command line
-
hf download hf://spaces/SreejithSHR/umami/src/lib/load.ts
-
curl -L -o load.ts https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/load.ts
1 kB
| import { getWebsiteSession, getWebsite } from 'queries'; | |
| import { Website, Session } from '@prisma/client'; | |
| import { getClient, redisEnabled } from '@umami/redis-client'; | |
| export async function fetchWebsite(websiteId: string): Promise<Website> { | |
| let website = null; | |
| if (redisEnabled) { | |
| const redis = getClient(); | |
| website = await redis.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400); | |
| } else { | |
| website = await getWebsite(websiteId); | |
| } | |
| if (!website || website.deletedAt) { | |
| return null; | |
| } | |
| return website; | |
| } | |
| export async function fetchSession(websiteId: string, sessionId: string): Promise<Session> { | |
| let session = null; | |
| if (redisEnabled) { | |
| const redis = getClient(); | |
| session = await redis.fetch( | |
| `session:${sessionId}`, | |
| () => getWebsiteSession(websiteId, sessionId), | |
| 86400, | |
| ); | |
| } else { | |
| session = await getWebsiteSession(websiteId, sessionId); | |
| } | |
| if (!session) { | |
| return null; | |
| } | |
| return session; | |
| } | |