mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
use uuid
This commit is contained in:
parent
246e4e5f4f
commit
17041efaae
73 changed files with 491 additions and 874 deletions
|
|
@ -19,7 +19,6 @@ async function relationalQuery(websiteId, data) {
|
|||
},
|
||||
select: {
|
||||
id: true,
|
||||
sessionUuid: true,
|
||||
hostname: true,
|
||||
browser: true,
|
||||
os: true,
|
||||
|
|
@ -31,7 +30,7 @@ async function relationalQuery(websiteId, data) {
|
|||
})
|
||||
.then(async res => {
|
||||
if (redis.enabled && res) {
|
||||
await redis.set(`session:${res.sessionUuid}`, 1);
|
||||
await redis.set(`session:${res.id}`, 1);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
@ -40,12 +39,12 @@ async function relationalQuery(websiteId, data) {
|
|||
|
||||
async function clickhouseQuery(
|
||||
websiteId,
|
||||
{ sessionUuid, hostname, browser, os, screen, language, country, device },
|
||||
{ sessionId, hostname, browser, os, screen, language, country, device },
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
|
||||
const params = {
|
||||
session_uuid: sessionUuid,
|
||||
sessionId,
|
||||
website_id: websiteId,
|
||||
created_at: getDateFormat(new Date()),
|
||||
hostname,
|
||||
|
|
@ -60,6 +59,6 @@ async function clickhouseQuery(
|
|||
await sendMessage(params, 'event');
|
||||
|
||||
if (redis.enabled) {
|
||||
await redis.set(`session:${sessionUuid}`, 1);
|
||||
await redis.set(`session:${sessionId}`, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,17 @@ import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
|||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function getSessionByUuid(...args) {
|
||||
export async function getSession(...args) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(sessionUuid) {
|
||||
async function relationalQuery(where) {
|
||||
return prisma.client.session
|
||||
.findUnique({
|
||||
where: {
|
||||
sessionUuid,
|
||||
},
|
||||
where,
|
||||
})
|
||||
.then(async res => {
|
||||
if (redis.enabled && res) {
|
||||
|
|
@ -49,7 +47,7 @@ async function clickhouseQuery(sessionUuid) {
|
|||
.then(result => findFirst(result))
|
||||
.then(async res => {
|
||||
if (redis.enabled && res) {
|
||||
await redis.set(`session:${res.session_uuid}`, 1);
|
||||
await redis.set(`session:${res.id}`, 1);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
@ -23,7 +23,7 @@ async function relationalQuery(websiteId, { startDate, endDate, field, filters =
|
|||
join website
|
||||
on pageview.website_id = website.website_id
|
||||
${joinSession}
|
||||
where website.website_uuid='${websiteId}'
|
||||
where website.website_id='${websiteId}'
|
||||
and pageview.created_at between $1 and $2
|
||||
${pageviewQuery}
|
||||
${sessionQuery}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ async function relationalQuery(websites, start_at) {
|
|||
...(websites && websites.length > 0
|
||||
? {
|
||||
website: {
|
||||
websiteUuid: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue