Skip to content

Commit

Permalink
cloud_functions: reduce prices requested
Browse files Browse the repository at this point in the history
  • Loading branch information
panoel committed Sep 21, 2023
1 parent 6ad3f6f commit f8d93e1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloud_functions/src/computeTvlTvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ async function getTokenPrices(): Promise<TokenPrice[]> {
},
});
// get all of the known coin IDs
const today = new Date(Date.now()).toISOString().slice(0, 10);
const rows = await pg(assertEnvironmentVariable('PG_TOKEN_PRICE_HISTORY_TABLE'))
.select('*')
.whereNotNull('coin_gecko_coin_id')
.andWhere('date', '=', today)
.distinct();
return rows;
} catch (e) {
Expand Down Expand Up @@ -116,6 +118,7 @@ async function populateMaps() {

// Lastly, get the price information
const prices: TokenPrice[] = await getTokenPrices();
console.log(`Got ${prices.length} token prices`);
for (const p of prices) {
// Check the date on the price. Only use the latest.
const existingPrice = priceMap.get(p.coin_gecko_coin_id);
Expand Down

0 comments on commit f8d93e1

Please sign in to comment.