select only session id

pull/572/head
formica2 2021-03-25 16:58:55 +03:00
parent f8ac987bfc
commit 541b103338
2 changed files with 15 additions and 2 deletions

View File

@ -182,6 +182,19 @@ export async function getSessionByUuid(session_uuid) {
);
}
export async function getSessionIDByUuid(session_uuid) {
return runQuery(
prisma.session.findUnique({
where: {
session_uuid,
},
select: {
session_id: true,
}
}),
);
}
export async function savePageView(website_id, session_id, url, referrer) {
return runQuery(
prisma.pageview.create({

View File

@ -1,4 +1,4 @@
import { getWebsiteByUuid, getSessionByUuid, createSession } from 'lib/queries';
import { getWebsiteByUuid, getSessionIDByUuid, createSession } from 'lib/queries';
import { getClientInfo } from 'lib/request';
import { uuid, isValidUuid, parseToken } from 'lib/crypto';
@ -34,7 +34,7 @@ export async function getSession(req) {
const { website_id } = website;
const session_uuid = uuid(website_id, hostname, ip, userAgent, os);
let session = await getSessionByUuid(session_uuid);
let session = await getSessionIDByUuid(session_uuid);
if (!session) {
session = await createSession(website_id, {