mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
roll back id adds
This commit is contained in:
parent
ec6454aead
commit
4073d57e64
@ -60,8 +60,8 @@ function getDateFormat(date) {
|
|||||||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommaSeparatedStringFormat(data, column) {
|
function getCommaSeparatedStringFormat(data) {
|
||||||
return data.map(obj => `'${obj[column]}'`).join(',');
|
return data.map(a => `'${a}'`).join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBetweenDates(field, start_at, end_at) {
|
function getBetweenDates(field, start_at, end_at) {
|
||||||
|
@ -14,9 +14,8 @@ export default async (req, res) => {
|
|||||||
const { id } = req.query;
|
const { id } = req.query;
|
||||||
|
|
||||||
const websiteId = +id;
|
const websiteId = +id;
|
||||||
const website_uuid = id;
|
|
||||||
|
|
||||||
const result = await getActiveVisitors(websiteId, website_uuid);
|
const result = await getActiveVisitors(websiteId);
|
||||||
|
|
||||||
return ok(res, result);
|
return ok(res, result);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,10 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const websiteId = +id;
|
const websiteId = +id;
|
||||||
const website_uuid = id;
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+start_at);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
const events = await getEventMetrics(websiteId, website_uuid, startDate, endDate, tz, unit, {
|
const events = await getEventMetrics(websiteId, startDate, endDate, tz, unit, {
|
||||||
url,
|
url,
|
||||||
eventName: event_name,
|
eventName: event_name,
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,6 @@ export default async (req, res) => {
|
|||||||
const { id, type, start_at, end_at, url, referrer, os, browser, device, country } = req.query;
|
const { id, type, start_at, end_at, url, referrer, os, browser, device, country } = req.query;
|
||||||
|
|
||||||
const websiteId = +id;
|
const websiteId = +id;
|
||||||
const website_uuid = id;
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+start_at);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ export default async (req, res) => {
|
|||||||
query: type === 'query' && table !== 'event' ? true : undefined,
|
query: type === 'query' && table !== 'event' ? true : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = await getPageviewMetrics(websiteId, website_uuid, {
|
const data = await getPageviewMetrics(websiteId, {
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
column,
|
column,
|
||||||
|
@ -18,7 +18,6 @@ export default async (req, res) => {
|
|||||||
req.query;
|
req.query;
|
||||||
|
|
||||||
const websiteId = +id;
|
const websiteId = +id;
|
||||||
const website_uuid = id;
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+start_at);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [pageviews, sessions] = await Promise.all([
|
const [pageviews, sessions] = await Promise.all([
|
||||||
getPageviewStats(websiteId, website_uuid, {
|
getPageviewStats(websiteId, {
|
||||||
start_at: startDate,
|
start_at: startDate,
|
||||||
end_at: endDate,
|
end_at: endDate,
|
||||||
timezone: tz,
|
timezone: tz,
|
||||||
@ -42,7 +41,7 @@ export default async (req, res) => {
|
|||||||
country,
|
country,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
getPageviewStats(websiteId, website_uuid, {
|
getPageviewStats(websiteId, {
|
||||||
start_at: startDate,
|
start_at: startDate,
|
||||||
end_at: endDate,
|
end_at: endDate,
|
||||||
timezone: tz,
|
timezone: tz,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getWebsiteStats, getWebsiteById } from 'queries';
|
import { getWebsiteStats } from 'queries';
|
||||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||||
import { allowQuery } from 'lib/auth';
|
import { allowQuery } from 'lib/auth';
|
||||||
import { useCors } from 'lib/middleware';
|
import { useCors } from 'lib/middleware';
|
||||||
@ -14,7 +14,6 @@ export default async (req, res) => {
|
|||||||
const { website_id, start_at, end_at, url, referrer, os, browser, device, country } = req.query;
|
const { website_id, start_at, end_at, url, referrer, os, browser, device, country } = req.query;
|
||||||
|
|
||||||
const websiteId = +website_id;
|
const websiteId = +website_id;
|
||||||
let websiteUuid = (await getWebsiteById(websiteId)).websiteUuid;
|
|
||||||
const startDate = new Date(+start_at);
|
const startDate = new Date(+start_at);
|
||||||
const endDate = new Date(+end_at);
|
const endDate = new Date(+end_at);
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ export default async (req, res) => {
|
|||||||
const prevStartDate = new Date(+start_at - distance);
|
const prevStartDate = new Date(+start_at - distance);
|
||||||
const prevEndDate = new Date(+end_at - distance);
|
const prevEndDate = new Date(+end_at - distance);
|
||||||
|
|
||||||
const metrics = await getWebsiteStats(websiteUuid, {
|
const metrics = await getWebsiteStats(websiteId, {
|
||||||
start_at: startDate,
|
start_at: startDate,
|
||||||
end_at: endDate,
|
end_at: endDate,
|
||||||
filters: {
|
filters: {
|
||||||
@ -34,7 +33,7 @@ export default async (req, res) => {
|
|||||||
country,
|
country,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const prevPeriod = await getWebsiteStats(websiteUuid, {
|
const prevPeriod = await getWebsiteStats(websiteId, {
|
||||||
start_at: prevStartDate,
|
start_at: prevStartDate,
|
||||||
end_at: prevEndDate,
|
end_at: prevEndDate,
|
||||||
filters: {
|
filters: {
|
||||||
|
@ -37,7 +37,6 @@ async function relationalQuery(
|
|||||||
|
|
||||||
async function clickhouseQuery(
|
async function clickhouseQuery(
|
||||||
websiteId,
|
websiteId,
|
||||||
website_uuid,
|
|
||||||
start_at,
|
start_at,
|
||||||
end_at,
|
end_at,
|
||||||
timezone = 'UTC',
|
timezone = 'UTC',
|
||||||
|
@ -39,7 +39,7 @@ function clickhouseQuery(websites, start_at) {
|
|||||||
where event_name != ''
|
where event_name != ''
|
||||||
and ${
|
and ${
|
||||||
websites && websites.length > 0
|
websites && websites.length > 0
|
||||||
? `website_id in (${getCommaSeparatedStringFormat(websites, websites.website_uuid)})`
|
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||||
: '0 = 0'
|
: '0 = 0'
|
||||||
}
|
}
|
||||||
and created_at >= ${getDateFormat(start_at)}`,
|
and created_at >= ${getDateFormat(start_at)}`,
|
||||||
|
@ -34,15 +34,13 @@ async function relationalQuery(websiteId, { sessionId, url, eventName, eventData
|
|||||||
async function clickhouseQuery(
|
async function clickhouseQuery(
|
||||||
websiteId,
|
websiteId,
|
||||||
{ session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },
|
{ session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },
|
||||||
website_uuid,
|
|
||||||
) {
|
) {
|
||||||
const { getDateFormat, sendMessage } = kafka;
|
const { getDateFormat, sendMessage } = kafka;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
session_uuid: sessionUuid,
|
session_id: sessionUuid,
|
||||||
event_uuid: eventUuid,
|
event_id: eventUuid,
|
||||||
website_id: websiteId,
|
website_id: websiteId,
|
||||||
website_uuid,
|
|
||||||
created_at: getDateFormat(new Date()),
|
created_at: getDateFormat(new Date()),
|
||||||
url: url?.substring(0, URL_LENGTH),
|
url: url?.substring(0, URL_LENGTH),
|
||||||
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||||
|
@ -37,7 +37,7 @@ async function clickhouseQuery(websites, start_at) {
|
|||||||
where event_name = ''
|
where event_name = ''
|
||||||
and ${
|
and ${
|
||||||
websites && websites.length > 0
|
websites && websites.length > 0
|
||||||
? `website_id in (${getCommaSeparatedStringFormat(websites, websites.website_uuid)})`
|
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||||
: '0 = 0'
|
: '0 = 0'
|
||||||
}
|
}
|
||||||
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user