mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
add timestamp column to prisma realtime queries
This commit is contained in:
parent
8a4fe95a72
commit
29694352e7
2 changed files with 38 additions and 20 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue