Skip to content

Commit 42b83a9

Browse files
authored
Merge pull request #15611 from ethereum/gtp-7d
feat: use 7d growthepie endpoint
2 parents 0755f42 + 61ce01d commit 42b83a9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/lib/api/fetchGrowThePie.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,19 @@ const TXCOUNT = "txcount"
1414
const ACTIVE_ADDRESSES = "aa_last7d"
1515

1616
export const fetchGrowThePie = async (): Promise<GrowThePieData> => {
17-
const url = "https://api.growthepie.xyz/v1/fundamentals.json"
17+
const url = "https://api.growthepie.xyz/v1/fundamentals_7d.json"
1818

19-
const response = await fetch(url, { cache: "no-store" })
19+
const response = await fetch(url)
2020
if (!response.ok) {
2121
console.log(response.status, response.statusText)
2222
throw new Error("Failed to fetch growthepie data")
2323
}
2424
const data: DataItem[] = await response.json()
2525

26-
// Get the date 7 days ago
27-
const sevenDaysAgo = new Date()
28-
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7)
29-
30-
// Filter data to only include the last 7 days and the metrics we need
31-
const filteredData = data.filter((item) => {
32-
const itemDate = new Date(item.date)
33-
return (
34-
itemDate >= sevenDaysAgo &&
35-
[TXCOSTS_MEDIAN_USD, TXCOUNT, ACTIVE_ADDRESSES].includes(item.metric_key)
36-
)
37-
})
26+
// Filter data to only include the metrics we need
27+
const filteredData = data.filter((item) =>
28+
[TXCOSTS_MEDIAN_USD, TXCOUNT, ACTIVE_ADDRESSES].includes(item.metric_key)
29+
)
3830

3931
const mostRecentDate = filteredData.reduce((latest, item) => {
4032
const itemDate = new Date(item.date)

0 commit comments

Comments
 (0)