mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
Refactored send. Purged pages api routes.
This commit is contained in:
parent
5205551ca8
commit
85382e25af
69 changed files with 286 additions and 4118 deletions
|
|
@ -1,26 +1,20 @@
|
|||
import { serializeError } from 'serialize-error';
|
||||
import { getWebsiteSession, getWebsite } from 'queries';
|
||||
import { Website, Session } from '@prisma/client';
|
||||
import { getClient, redisEnabled } from '@umami/redis-client';
|
||||
import { getWebsiteSession, getWebsite } from 'queries';
|
||||
|
||||
export async function fetchWebsite(websiteId: string): Promise<Website> {
|
||||
let website = null;
|
||||
|
||||
try {
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
|
||||
website = await redis.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
|
||||
} else {
|
||||
website = await getWebsite(websiteId);
|
||||
}
|
||||
website = await redis.fetch(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
|
||||
} else {
|
||||
website = await getWebsite(websiteId);
|
||||
}
|
||||
|
||||
if (!website || website.deletedAt) {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('FETCH WEBSITE ERROR:', serializeError(e));
|
||||
if (!website || website.deletedAt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return website;
|
||||
|
|
@ -29,21 +23,16 @@ export async function fetchWebsite(websiteId: string): Promise<Website> {
|
|||
export async function fetchSession(websiteId: string, sessionId: string): Promise<Session> {
|
||||
let session = null;
|
||||
|
||||
try {
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
if (redisEnabled) {
|
||||
const redis = getClient();
|
||||
|
||||
session = await redis.fetch(
|
||||
`session:${sessionId}`,
|
||||
() => getWebsiteSession(websiteId, sessionId),
|
||||
86400,
|
||||
);
|
||||
} else {
|
||||
session = await getWebsiteSession(websiteId, sessionId);
|
||||
}
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('FETCH SESSION ERROR:', serializeError(e));
|
||||
session = await redis.fetch(
|
||||
`session:${sessionId}`,
|
||||
() => getWebsiteSession(websiteId, sessionId),
|
||||
86400,
|
||||
);
|
||||
} else {
|
||||
session = await getWebsiteSession(websiteId, sessionId);
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue