mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Fixed date parsing in database queries.
This commit is contained in:
parent
2ce2885b44
commit
07cc61f5c3
3 changed files with 38 additions and 16 deletions
|
|
@ -95,17 +95,22 @@ export function getDateArray(data, startDate, endDate, unit) {
|
|||
const arr = [];
|
||||
const [diff, add, normalize] = dateFuncs[unit];
|
||||
const n = diff(endDate, startDate) + 1;
|
||||
console.log({ startDate, endDate, n });
|
||||
|
||||
function findData(t) {
|
||||
const x = data.find(e => {
|
||||
return getLocalTime(new Date(e.t)).getTime() === normalize(new Date(t)).getTime();
|
||||
if (unit === 'day') {
|
||||
const [year, month, day] = e.t.split('-');
|
||||
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
|
||||
}
|
||||
return normalize(new Date(e.t)).getTime() === t.getTime();
|
||||
});
|
||||
|
||||
return x?.y || 0;
|
||||
}
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const t = add(startDate, i);
|
||||
const t = normalize(add(startDate, i));
|
||||
const y = findData(t);
|
||||
|
||||
arr.push({ ...data[i], t, y });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue