mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Refactored queries.
This commit is contained in:
parent
18e36aa7b3
commit
b16f5cc067
67 changed files with 523 additions and 576 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import { User, Website } from '@prisma/client';
|
||||
import redis from '@umami/redis-client';
|
||||
import { getSession, getUserById, getWebsiteById } from '../queries';
|
||||
import { getSession, getUser, getWebsite } from '../queries';
|
||||
|
||||
async function fetchWebsite(id): Promise<Website> {
|
||||
return redis.client.getCache(`website:${id}`, () => getWebsiteById(id), 86400);
|
||||
async function fetchWebsite(websiteId: string): Promise<Website> {
|
||||
return redis.client.getCache(`website:${websiteId}`, () => getWebsite(websiteId), 86400);
|
||||
}
|
||||
|
||||
async function storeWebsite(data) {
|
||||
async function storeWebsite(data: { id: any }) {
|
||||
const { id } = data;
|
||||
const key = `website:${id}`;
|
||||
|
||||
|
|
@ -21,11 +21,7 @@ async function deleteWebsite(id) {
|
|||
}
|
||||
|
||||
async function fetchUser(id): Promise<User> {
|
||||
return redis.client.getCache(
|
||||
`user:${id}`,
|
||||
() => getUserById(id, { includePassword: true }),
|
||||
86400,
|
||||
);
|
||||
return redis.client.getCache(`user:${id}`, () => getUser(id, { includePassword: true }), 86400);
|
||||
}
|
||||
|
||||
async function storeUser(data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue