Skip to content

Commit

Permalink
fix: isNan
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Dec 7, 2023
1 parent 23413d8 commit be25d7c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions dashboard/src/scenes/stats/PersonsStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,22 +275,19 @@ const BlockCreatedAt = ({ persons }) => {

const outOfActiveListEntries = history.filter((hist) => hist.data.outOfActiveListDate);
if (!outOfActiveListEntries.length) {
// person never became inactive, so calculate followed time until now
totalFollowedTime += Date.now() - followStart;
} else {
for (const historyEntry of outOfActiveListEntries) {
if (historyEntry.data.outOfActiveList.newValue === true) {
const outOfActiveListDate = historyEntry.data.outOfActiveListDate.newValue;
const formattedDate = typeof outOfActiveListDate === 'number' ? outOfActiveListDate : Date.parse(outOfActiveListDate);

// person became inactive, so calculate followed time
totalFollowedTime += formattedDate - followStart;
if (!isNaN(formattedDate)) {
totalFollowedTime += formattedDate - followStart;
}
} else {
// person became active, so update start
followStart = Date.parse(historyEntry.date); // assuming that this correctly reflects when the person became active
followStart = Date.parse(historyEntry.date);
}
}
// if the person is still active, add time from last followStart to now
if (!person.outOfActiveList) {
totalFollowedTime += Date.now() - followStart;
}
Expand Down

0 comments on commit be25d7c

Please sign in to comment.