-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1210 from Ekep-Obasi/fix/error-on-initial-loading…
…-for-new-graph fix: corrected computation of `splashDataLoaded`
- Loading branch information
Showing
14 changed files
with
103 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { initialMessageData } from '~/components/App/Splash/constants' | ||
import { StatsConfig } from '~/components/Stats' | ||
import { TStatParams } from '~/network/fetchSourcesData' | ||
import { TStats } from '~/types' | ||
import { formatNumberWithCommas } from '../formatStats' | ||
|
||
/** | ||
* Formats the statistics response object. | ||
* @param statsRespons {TStatParams} The statistics response object from /stats to format. | ||
* @returns {TStats} The formatted statistics object. | ||
*/ | ||
|
||
export const formatStatsResponse = (statsResponse: TStatParams): TStats => | ||
StatsConfig.reduce((updatedStats: TStats, { key, dataKey }) => { | ||
const formattedValue = formatNumberWithCommas(statsResponse[dataKey] ?? 0) | ||
|
||
return { ...updatedStats, [key]: formattedValue } | ||
}, {}) | ||
|
||
/** | ||
* Formats the splash message based on the statistics response. | ||
* @param statsRespons {TStatParams} The statistics response object from /stats to format. | ||
* @returns The formatted splash message array. | ||
*/ | ||
|
||
export const formatSplashMessage = (statsResponse: TStatParams) => | ||
// Map over initialMessageData to format each message | ||
initialMessageData.map(({ dataKey, ...rest }) => ({ | ||
// Spread the rest of the properties and add the formatted value | ||
...rest, | ||
value: formatNumberWithCommas(statsResponse[dataKey] ?? 0), | ||
})) |