mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 18:00:17 +01:00
Fixed summary query.
This commit is contained in:
parent
0c8d9eacd3
commit
344ffeb658
@ -13,7 +13,8 @@
|
|||||||
},
|
},
|
||||||
"plugins": ["react"],
|
"plugins": ["react"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"react/react-in-jsx-scope": "off"
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"react/prop-types": "off"
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"React": "writable"
|
"React": "writable"
|
||||||
|
@ -15,7 +15,7 @@ export default function PageviewsChart({ data, unit }) {
|
|||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 'day':
|
case 'day':
|
||||||
if (n > 7) {
|
if (n > 7) {
|
||||||
return index % (n / 15) === 0 ? format(d, 'MMM d') : '';
|
return index % ~~(n / 15) === 0 ? format(d, 'MMM d') : '';
|
||||||
}
|
}
|
||||||
return format(d, 'EEE M/d');
|
return format(d, 'EEE M/d');
|
||||||
default:
|
default:
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
"cookie": "^0.4.1",
|
"cookie": "^0.4.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"date-fns": "^2.14.0",
|
"date-fns": "^2.14.0",
|
||||||
|
"date-fns-tz": "^1.0.10",
|
||||||
"detect-browser": "^5.1.1",
|
"detect-browser": "^5.1.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"formik": "^2.1.5",
|
"formik": "^2.1.5",
|
||||||
|
@ -11,9 +11,12 @@ export default async (req, res) => {
|
|||||||
return res.status(400).end();
|
return res.status(400).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const start = new Date(+start_at);
|
||||||
|
const end = new Date(+end_at);
|
||||||
|
|
||||||
const [pageviews, uniques] = await Promise.all([
|
const [pageviews, uniques] = await Promise.all([
|
||||||
getPageviewData(+id, new Date(+start_at), new Date(+end_at), tz, unit, '*'),
|
getPageviewData(+id, start, end, tz, unit, '*'),
|
||||||
getPageviewData(+id, new Date(+start_at), new Date(+end_at), tz, unit, 'distinct session_id'),
|
getPageviewData(+id, start, end, tz, unit, 'distinct session_id'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return res.status(200).json({ pageviews, uniques });
|
return res.status(200).json({ pageviews, uniques });
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { getSummary } from 'lib/db';
|
import { getSummary } from 'lib/db';
|
||||||
import { useAuth } from 'lib/middleware';
|
import { useAuth } from 'lib/middleware';
|
||||||
import { format } from 'date-fns';
|
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
await useAuth(req, res);
|
await useAuth(req, res);
|
||||||
@ -9,8 +8,8 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
const summary = await getSummary(
|
const summary = await getSummary(
|
||||||
+id,
|
+id,
|
||||||
format(new Date(+start_at), 'yyyy-MM-dd hh:mm:ss'),
|
new Date(+start_at).toISOString(),
|
||||||
format(new Date(+end_at), 'yyyy-MM-dd hh:mm:ss'),
|
new Date(+end_at).toISOString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const stats = Object.keys(summary[0]).reduce((obj, key) => {
|
const stats = Object.keys(summary[0]).reduce((obj, key) => {
|
||||||
|
@ -3007,6 +3007,11 @@ d@1, d@^1.0.1:
|
|||||||
es5-ext "^0.10.50"
|
es5-ext "^0.10.50"
|
||||||
type "^1.0.1"
|
type "^1.0.1"
|
||||||
|
|
||||||
|
date-fns-tz@^1.0.10:
|
||||||
|
version "1.0.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/date-fns-tz/-/date-fns-tz-1.0.10.tgz#30fef0038f80534fddd8e133a6b8ca55ba313748"
|
||||||
|
integrity sha512-cHQAz0/9uDABaUNDM80Mj1FL4ODlxs1xEY4b0DQuAooO2UdNKvDkNbV8ogLnxLbv02Ru1HXFcot0pVvDRBgptg==
|
||||||
|
|
||||||
date-fns@^2.14.0:
|
date-fns@^2.14.0:
|
||||||
version "2.14.0"
|
version "2.14.0"
|
||||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
|
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
|
||||||
|
Loading…
Reference in New Issue
Block a user