mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-17 11:32:16 +00:00
fix preening when history entries are null
This commit is contained in:
parent
81ffcf9c1b
commit
573f2e4732
1 changed files with 2 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ export function preenHistory (history, isSubscribed, timezoneOffset = 0, dayStar
|
|||
|
||||
// Keep uncompressed entries (modifies history and returns removed items)
|
||||
let newHistory = _.remove(history, entry => {
|
||||
if (!entry) return true; // sometimes entries are `null`
|
||||
const entryDate = moment(entry.date).zone(timezoneOffset);
|
||||
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
||||
return entryDate.isSame(cutOff) || entryDate.isAfter(cutOff);
|
||||
|
|
@ -49,6 +50,7 @@ export function preenHistory (history, isSubscribed, timezoneOffset = 0, dayStar
|
|||
// Date after which to begin compressing data by year
|
||||
let monthsCutOff = cutOff.subtract(isSubscribed ? 12 : 10, 'months').startOf('day');
|
||||
let aggregateByMonth = _.remove(history, entry => {
|
||||
if (!entry) return true; // sometimes entries are `null`
|
||||
const entryDate = moment(entry.date).zone(timezoneOffset);
|
||||
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
||||
return entryDate.isSame(monthsCutOff) || entryDate.isAfter(monthsCutOff);
|
||||
|
|
|
|||
Loading…
Reference in a new issue