Skip to content

Commit

Permalink
fix: wrong logic in appending data of statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jan 18, 2024
1 parent 987112b commit df05649
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/statistics/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export function Statistics(props: FormProps) {
superLikeDataPromise,
] as const)

console.log(superLikeData)

combineOldLikesAndSuperLikes(statisticsDataArr, superLikeData)

if (isMounted) {
Expand Down Expand Up @@ -240,6 +242,7 @@ function combineOldLikesAndSuperLikes(
const likesStat = stats.find(
stat => stat.activityType === 'PostReactionCreated,CommentReactionCreated',
)
console.log(likesStat, stats)
if (!likesStat) return stats

const totalSuperLikes = superLikesStats.reduce((acc, stat) => acc + stat.count, 0)
Expand All @@ -251,7 +254,7 @@ function combineOldLikesAndSuperLikes(
likesStat.statisticsData.forEach(stat => allLikesMap.set(stat.format_date, stat))

superLikesStats.forEach(stat => {
const dateFormat = dayjs(stat.dayUnixTimestamp).format('YYYY-MM-DD')
const dateFormat = dayjs(stat.dayUnixTimestamp * 1000).format('YYYY-MM-DD')
const existingStat = allLikesMap.get(dateFormat)
if (existingStat) {
existingStat.count += stat.count
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/datahub/active-staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export async function getSuperLikesStats(period: number): Promise<SuperLikesStat
const { day: startTimestamp } = getDayAndWeekTimestamp(currentMinusPeriod)
const res = await datahubQueryRequest<
{
activeStakingSuperLikeCountsByData: {
activeStakingSuperLikeCountsByDate: {
count: number
dayUnixTimestamp: number
}[]
Expand All @@ -304,7 +304,7 @@ export async function getSuperLikesStats(period: number): Promise<SuperLikesStat
variables: { from: startTimestamp.toString(), to: currentTimestamp.toString() },
})

return res.activeStakingSuperLikeCountsByData
return res.activeStakingSuperLikeCountsByDate
}

// MUTATIONS
Expand Down

0 comments on commit df05649

Please sign in to comment.