mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Database refactoring.
This commit is contained in:
parent
bb184dc2cc
commit
467c7f289f
37 changed files with 566 additions and 591 deletions
|
|
@ -1,32 +1,28 @@
|
|||
import { CLICKHOUSE, RELATIONAL } from 'lib/constants';
|
||||
import { prisma, runQuery } from 'lib/relational';
|
||||
import prisma from 'lib/prisma';
|
||||
import clickhouse from 'lib/clickhouse';
|
||||
import { runAnalyticsQuery } from 'lib/db';
|
||||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
|
||||
export async function getSessionByUuid(...args) {
|
||||
return runAnalyticsQuery({
|
||||
[RELATIONAL]: () => relationalQuery(...args),
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(...args),
|
||||
[CLICKHOUSE]: () => clickhouseQuery(...args),
|
||||
});
|
||||
}
|
||||
|
||||
async function relationalQuery(session_uuid) {
|
||||
return runQuery(
|
||||
prisma.session.findUnique({
|
||||
where: {
|
||||
session_uuid,
|
||||
},
|
||||
}),
|
||||
);
|
||||
return prisma.client.session.findUnique({
|
||||
where: {
|
||||
session_uuid,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function clickhouseQuery(session_uuid) {
|
||||
const { rawQuery, findFirst } = clickhouse;
|
||||
const params = [session_uuid];
|
||||
|
||||
return clickhouse
|
||||
.rawQuery(
|
||||
`
|
||||
select
|
||||
return rawQuery(
|
||||
`select
|
||||
session_uuid,
|
||||
website_id,
|
||||
created_at,
|
||||
|
|
@ -35,12 +31,10 @@ async function clickhouseQuery(session_uuid) {
|
|||
os,
|
||||
device,
|
||||
screen,
|
||||
"language",
|
||||
language,
|
||||
country
|
||||
from session
|
||||
where session_uuid = $1
|
||||
`,
|
||||
params,
|
||||
)
|
||||
.then(result => clickhouse.findFirst(result));
|
||||
where session_uuid = $1`,
|
||||
params,
|
||||
).then(result => findFirst(result));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue