select only session id
parent
f8ac987bfc
commit
541b103338
|
@ -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({
|
||||
|
|
|
@ -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, {
|
||||
|
|
Loading…
Reference in New Issue