mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 02:06:19 +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')}'`;
|
||||
}
|
||||
|
||||
function getCommaSeparatedStringFormat(data, column) {
|
||||
return data.map(obj => `'${obj[column]}'`).join(',');
|
||||
function getCommaSeparatedStringFormat(data) {
|
||||
return data.map(a => `'${a}'`).join(',');
|
||||
}
|
||||
|
||||
function getBetweenDates(field, start_at, end_at) {
|
||||
|
@ -14,9 +14,8 @@ export default async (req, res) => {
|
||||
const { id } = req.query;
|
||||
|
||||
const websiteId = +id;
|
||||
const website_uuid = id;
|
||||
|
||||
const result = await getActiveVisitors(websiteId, website_uuid);
|
||||
const result = await getActiveVisitors(websiteId);
|
||||
|
||||
return ok(res, result);
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
const websiteId = +id;
|
||||
const website_uuid = id;
|
||||
const startDate = new Date(+start_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,
|
||||
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 websiteId = +id;
|
||||
const website_uuid = id;
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
@ -107,7 +106,7 @@ export default async (req, res) => {
|
||||
query: type === 'query' && table !== 'event' ? true : undefined,
|
||||
};
|
||||
|
||||
const data = await getPageviewMetrics(websiteId, website_uuid, {
|
||||
const data = await getPageviewMetrics(websiteId, {
|
||||
startDate,
|
||||
endDate,
|
||||
column,
|
||||
|
@ -18,7 +18,6 @@ export default async (req, res) => {
|
||||
req.query;
|
||||
|
||||
const websiteId = +id;
|
||||
const website_uuid = id;
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
@ -27,7 +26,7 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
const [pageviews, sessions] = await Promise.all([
|
||||
getPageviewStats(websiteId, website_uuid, {
|
||||
getPageviewStats(websiteId, {
|
||||
start_at: startDate,
|
||||
end_at: endDate,
|
||||
timezone: tz,
|
||||
@ -42,7 +41,7 @@ export default async (req, res) => {
|
||||
country,
|
||||
},
|
||||
}),
|
||||
getPageviewStats(websiteId, website_uuid, {
|
||||
getPageviewStats(websiteId, {
|
||||
start_at: startDate,
|
||||
end_at: endDate,
|
||||
timezone: tz,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getWebsiteStats, getWebsiteById } from 'queries';
|
||||
import { getWebsiteStats } from 'queries';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { allowQuery } from 'lib/auth';
|
||||
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 websiteId = +website_id;
|
||||
let websiteUuid = (await getWebsiteById(websiteId)).websiteUuid;
|
||||
const startDate = new Date(+start_at);
|
||||
const endDate = new Date(+end_at);
|
||||
|
||||
@ -22,7 +21,7 @@ export default async (req, res) => {
|
||||
const prevStartDate = new Date(+start_at - distance);
|
||||
const prevEndDate = new Date(+end_at - distance);
|
||||
|
||||
const metrics = await getWebsiteStats(websiteUuid, {
|
||||
const metrics = await getWebsiteStats(websiteId, {
|
||||
start_at: startDate,
|
||||
end_at: endDate,
|
||||
filters: {
|
||||
@ -34,7 +33,7 @@ export default async (req, res) => {
|
||||
country,
|
||||
},
|
||||
});
|
||||
const prevPeriod = await getWebsiteStats(websiteUuid, {
|
||||
const prevPeriod = await getWebsiteStats(websiteId, {
|
||||
start_at: prevStartDate,
|
||||
end_at: prevEndDate,
|
||||
filters: {
|
||||
|
@ -37,7 +37,6 @@ async function relationalQuery(
|
||||
|
||||
async function clickhouseQuery(
|
||||
websiteId,
|
||||
website_uuid,
|
||||
start_at,
|
||||
end_at,
|
||||
timezone = 'UTC',
|
||||
|
@ -39,7 +39,7 @@ function clickhouseQuery(websites, start_at) {
|
||||
where event_name != ''
|
||||
and ${
|
||||
websites && websites.length > 0
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites, websites.website_uuid)})`
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${getDateFormat(start_at)}`,
|
||||
|
@ -34,15 +34,13 @@ async function relationalQuery(websiteId, { sessionId, url, eventName, eventData
|
||||
async function clickhouseQuery(
|
||||
websiteId,
|
||||
{ session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },
|
||||
website_uuid,
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
|
||||
const params = {
|
||||
session_uuid: sessionUuid,
|
||||
event_uuid: eventUuid,
|
||||
session_id: sessionUuid,
|
||||
event_id: eventUuid,
|
||||
website_id: websiteId,
|
||||
website_uuid,
|
||||
created_at: getDateFormat(new Date()),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
|
@ -37,7 +37,7 @@ async function clickhouseQuery(websites, start_at) {
|
||||
where event_name = ''
|
||||
and ${
|
||||
websites && websites.length > 0
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites, websites.website_uuid)})`
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
||||
|
Loading…
Reference in New Issue
Block a user