Skip to content

Commit

Permalink
additional logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Nov 18, 2024
1 parent 3e62336 commit 672ae9a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/coingecko.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dayjs from 'dayjs'
import { Between, LessThanOrEqual } from 'typeorm'
import { parseEther } from 'viem'

Expand Down Expand Up @@ -90,9 +91,7 @@ export async function applyCoingeckoData(
} else {
whereClause.pegPrice = 0n
}
if (props.startTimestamp) {
whereClause.timestamp = Between(new Date(props.startTimestamp), getStartOfDayTimestamp())
}
whereClause.timestamp = Between(dayjs().subtract(365, 'day').toDate(), getStartOfDayTimestamp())
const statsWithNoPrice = await ctx.store.findBy(Entity as any, whereClause)

if (statsWithNoPrice.length > 0) {
Expand All @@ -119,6 +118,7 @@ export async function applyCoingeckoData(
if (!coingeckoJson) {
console.log('No coingeckoJson :(')
} else {
console.log('Processing coingecko data')
const coingeckData = processCoingeckoData(coingeckoJson)
for (const dayId in coingeckData) {
const stat = statsWithNoPrice.find((s) => s.id === dayId) as
Expand All @@ -131,7 +131,9 @@ export async function applyCoingeckoData(
if (stat && day.prices) {
stat.tradingVolumeUSD = day.total_volumes || 0
stat.marketCapUSD = day.market_caps || 0
if (stat instanceof OGVDailyStat || stat instanceof OGNDailyStat) {
console.log('stat', stat)
console.log('price data', day)
if ('priceUSD' in stat) {
stat.priceUSD = day.prices
} else {
stat.pegPrice = parseEther(String(day.prices))
Expand Down

0 comments on commit 672ae9a

Please sign in to comment.