Skip to content

Commit

Permalink
fix: nouveau calcul pour temps de suivi en prenant en compte la sorti…
Browse files Browse the repository at this point in the history
…e de file active
  • Loading branch information
rap2hpoutre committed Oct 24, 2023
1 parent ddb68a1 commit ec9fec3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dashboard/src/scenes/stats/Persons.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,20 @@ const BlockCreatedAt = ({ persons }) => {
</div>
);
}
const averageFollowedSince =
persons.reduce((total, person) => total + Date.parse(person.followedSince || person.createdAt), 0) / (persons.length || 1);
const durationFromNowToAverage = Date.now() - averageFollowedSince;
const [count, unit] = getDuration(durationFromNowToAverage);

const averageFollowedTime =
persons.reduce((total, person) => {
// On utilise followedSince si disponible, sinon createdAt
const startFollowedDate = Date.parse(person.followedSince || person.createdAt);

// Si outOfActiveList est à true et que outOfActiveListDate est disponible, on utilise cette date, sinon on utilise la date actuelle
const endFollowedDate = person.outOfActiveList && person.outOfActiveListDate ? Date.parse(person.outOfActiveListDate) : Date.now();

// On renvoie la différence entre les deux dates
return total + (endFollowedDate - startFollowedDate);
}, 0) / (persons.length || 1); // On divise par le nombre de personnes pour obtenir la moyenne

const [count, unit] = getDuration(averageFollowedTime);

return (
<div className="tw-basis-1/2 tw-px-4 tw-py-2 lg:tw-basis-1/3">
Expand Down

0 comments on commit ec9fec3

Please sign in to comment.