Skip to content

Commit

Permalink
tmp delete then insert, removing after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Oct 30, 2023
1 parent cdf6c47 commit f05ef89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.provenance.explorer.domain.entities

import io.provenance.explorer.OBJECT_MAPPER
import io.provenance.explorer.domain.core.sql.jsonb
import io.provenance.explorer.domain.extensions.startOfDay
import io.provenance.explorer.model.ChainAum
import io.provenance.explorer.model.ChainMarketRate
import io.provenance.explorer.model.CmcHistoricalQuote
Expand Down Expand Up @@ -281,6 +282,10 @@ class TokenHistoricalDailyRecord(id: EntityID<DateTime>) : Entity<DateTime>(id)
.limit(1)
.firstOrNull()
}

fun deleteByDate(date: DateTime) = transaction {
TokenHistoricalDailyTable.deleteWhere { TokenHistoricalDailyTable.timestamp eq date.startOfDay() }
}
}

var timestamp by TokenHistoricalDailyTable.timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ class AsyncService(
.map { it to emptyList<DlobHistorical>() }.toMap().toMutableMap()
var prevPrice = TokenHistoricalDailyRecord.lastKnownPriceForDate(startDate)

TokenHistoricalDailyRecord

baseMap.putAll(
dlobRes.buy
.filter { DateTime(it.trade_timestamp * 1000).startOfDay() != today }
Expand Down Expand Up @@ -339,7 +341,9 @@ class AsyncService(
)
)
).also { prevPrice = close }
TokenHistoricalDailyRecord.save(record.time_open.startOfDay(), record)
TokenHistoricalDailyRecord.deleteByDate(record.time_open.startOfDay())
val id = TokenHistoricalDailyRecord.save(record.time_open.startOfDay(), record)
logger.info("saving record ${record.time_open.startOfDay()} $record insert count ${id.insertedCount}")
}
}

Expand Down

0 comments on commit f05ef89

Please sign in to comment.