mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 23:33:37 +01:00
Updated merge logic.
This commit is contained in:
parent
9737127bb1
commit
db9b238585
@ -9,7 +9,7 @@ import PageviewsChart from '../metrics/PageviewsChart';
|
|||||||
import { getDateArray } from '../../lib/date';
|
import { getDateArray } from '../../lib/date';
|
||||||
|
|
||||||
function filterTime(data, time) {
|
function filterTime(data, time) {
|
||||||
return data.filter(({ created_at }) => new Date(created_at).getTime() > time);
|
return data.filter(({ created_at }) => new Date(created_at).getTime() >= time);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapData(data) {
|
function mapData(data) {
|
||||||
@ -66,11 +66,11 @@ export default function RealtimeDashboard() {
|
|||||||
setData(init.data);
|
setData(init.data);
|
||||||
} else if (updates) {
|
} else if (updates) {
|
||||||
const { pageviews, sessions, events } = updates;
|
const { pageviews, sessions, events } = updates;
|
||||||
const time = subMinutes(startOfMinute(new Date()), 30).getTime();
|
const minTime = subMinutes(startOfMinute(new Date()), 30).getTime();
|
||||||
setData(state => ({
|
setData(state => ({
|
||||||
pageviews: filterTime(state.pageviews, time).concat(pageviews),
|
pageviews: filterTime(state.pageviews, minTime).concat(filterTime(pageviews, lastTime)),
|
||||||
sessions: filterTime(state.sessions, time).concat(sessions),
|
sessions: filterTime(state.sessions, minTime).concat(filterTime(sessions, lastTime)),
|
||||||
events: filterTime(state.events, time).concat(events),
|
events: filterTime(state.events, minTime).concat(filterTime(events, lastTime)),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
setLastTime(Date.now());
|
setLastTime(Date.now());
|
||||||
|
Loading…
Reference in New Issue
Block a user