Skip to content

Commit

Permalink
fix: incohrent stats for first publication
Browse files Browse the repository at this point in the history
  • Loading branch information
MaGOs92 committed Jan 11, 2024
1 parent 5337bcc commit 89ff338
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/dashboard/charts/first-publication-evolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const FirstPublicationEvolutionChart = ({firstPublicationEvolutionResponse, inte
const data = useMemo(() => {
let responseData = firstPublicationEvolutionResponse
if (interval) {
responseData = firstPublicationEvolutionResponse.filter((_data, index) => index % interval === 0)
responseData = firstPublicationEvolutionResponse.reduce((acc, cur, index) => {
const curMonth = cur.date.split('-')[1]
const isLastOfMonth = index === firstPublicationEvolutionResponse.length - 1 || firstPublicationEvolutionResponse[index + 1].date.split('-')[1] !== curMonth

return isLastOfMonth ? [...acc, cur] : acc
}, [])
}

const labels = responseData.map(({date}) => {
Expand Down

0 comments on commit 89ff338

Please sign in to comment.