This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-13 11:25:14 +01:00
parent 034be63ac0
commit 7f2c0f6cf0
64 changed files with 5820 additions and 1160 deletions

View File

@@ -92,6 +92,11 @@ interface GetEventsOptions {
profile?: boolean | Prisma.ProfileSelect;
}
export async function getLiveVisitors(projectId: string) {
const keys = await redis.keys(`live:event:${projectId}:*`);
return keys.length;
}
export async function getEvents(sql: string, options: GetEventsOptions = {}) {
const events = await chQuery<IClickhouseEvent>(sql);
if (options.profile) {
@@ -186,7 +191,12 @@ export async function createEvent(payload: IServiceCreateEventPayload) {
});
redisPub.publish('event', JSON.stringify(transformEvent(event)));
redis.set(`live:event:${event.project_id}:${event.profile_id}`, '', 'EX', 10);
redis.set(
`live:event:${event.project_id}:${event.profile_id}`,
'',
'EX',
60 * 5
);
return {
...res,

View File

@@ -0,0 +1,12 @@
import { db } from '../prisma-client';
export function getShareOverviewById(id: string) {
return db.shareOverview.findFirst({
where: {
id,
},
include: {
project: true,
},
});
}