add timestamp column to prisma realtime queries
This commit is contained in:
@@ -13,17 +13,26 @@ export function getEvents(...args: [websiteId: string, filters: QueryFilters]) {
|
|||||||
function relationalQuery(websiteId: string, filters: QueryFilters) {
|
function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
const { startDate } = filters;
|
const { startDate } = filters;
|
||||||
|
|
||||||
return prisma.client.websiteEvent.findMany({
|
return prisma.client.websiteEvent
|
||||||
where: {
|
.findMany({
|
||||||
websiteId,
|
where: {
|
||||||
createdAt: {
|
websiteId,
|
||||||
gte: startDate,
|
createdAt: {
|
||||||
|
gte: startDate,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
orderBy: {
|
||||||
orderBy: {
|
createdAt: 'desc',
|
||||||
createdAt: 'desc',
|
},
|
||||||
},
|
})
|
||||||
});
|
.then(a => {
|
||||||
|
return Object.values(a).map(a => {
|
||||||
|
return {
|
||||||
|
...a,
|
||||||
|
timestamp: new Date(a.createdAt).getTime() / 1000,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||||
|
|||||||
@@ -13,17 +13,26 @@ export async function getSessions(...args: [websiteId: string, filters: QueryFil
|
|||||||
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
const { startDate } = filters;
|
const { startDate } = filters;
|
||||||
|
|
||||||
return prisma.client.session.findMany({
|
return prisma.client.session
|
||||||
where: {
|
.findMany({
|
||||||
websiteId,
|
where: {
|
||||||
createdAt: {
|
websiteId,
|
||||||
gte: startDate,
|
createdAt: {
|
||||||
|
gte: startDate,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
orderBy: {
|
||||||
orderBy: {
|
createdAt: 'desc',
|
||||||
createdAt: 'desc',
|
},
|
||||||
},
|
})
|
||||||
});
|
.then(a => {
|
||||||
|
return Object.values(a).map(a => {
|
||||||
|
return {
|
||||||
|
...a,
|
||||||
|
timestamp: new Date(a.createdAt).getTime() / 1000,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||||
|
|||||||
Reference in New Issue
Block a user