mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 09:05:36 +01:00
Added rev_id column. Updated redis calls.
This commit is contained in:
parent
a9112f39ec
commit
3485b6268b
18 changed files with 133 additions and 79 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import clickhouse from 'lib/clickhouse';
|
||||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function getPageviewMetrics(...args) {
|
||||
return runQuery({
|
||||
|
|
@ -37,13 +38,15 @@ async function relationalQuery(websiteId, { startDate, endDate, column, table, f
|
|||
|
||||
async function clickhouseQuery(websiteId, { startDate, endDate, column, filters = {} }) {
|
||||
const { rawQuery, parseFilters, getBetweenDates } = clickhouse;
|
||||
const params = [websiteId];
|
||||
const website = await redis.get(`website:${websiteId}`);
|
||||
const params = [websiteId, website?.revId || 0];
|
||||
const { pageviewQuery, sessionQuery, eventQuery } = parseFilters(column, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
`select ${column} x, count(*) y
|
||||
from event
|
||||
where website_id= $1
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
${column !== 'event_name' ? `and event_name = ''` : `and event_name != ''`}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${pageviewQuery}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import clickhouse from 'lib/clickhouse';
|
||||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function getPageviewStats(...args) {
|
||||
return runQuery({
|
||||
|
|
@ -51,7 +52,8 @@ async function clickhouseQuery(
|
|||
{ start_at, end_at, timezone = 'UTC', unit = 'day', count = '*', filters = {} },
|
||||
) {
|
||||
const { parseFilters, rawQuery, getDateStringQuery, getDateQuery, getBetweenDates } = clickhouse;
|
||||
const params = [websiteId];
|
||||
const website = await redis.get(`website:${websiteId}`);
|
||||
const params = [websiteId, website?.revId || 0];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { URL_LENGTH } from 'lib/constants';
|
|||
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
||||
import kafka from 'lib/kafka';
|
||||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function savePageView(...args) {
|
||||
return runQuery({
|
||||
|
|
@ -29,6 +30,7 @@ async function clickhouseQuery(
|
|||
websiteId,
|
||||
{ session: { country, id: sessionId, ...sessionArgs }, url, referrer },
|
||||
) {
|
||||
const website = await redis.get(`website:${websiteId}`);
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
const params = {
|
||||
session_id: sessionId,
|
||||
|
|
@ -36,6 +38,7 @@ async function clickhouseQuery(
|
|||
created_at: getDateFormat(new Date()),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
rev_id: website?.revId || 0,
|
||||
...sessionArgs,
|
||||
country: country ? country : null,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue