diff --git a/CHANGELOG.md b/CHANGELOG.md index e7eea78d..c5d76ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Remove spotlight from caching to the database [#532](https://github.com/provenance-io/explorer-service/issues/532) * Update keep alive times for flow api grpc calls [#558](https://github.com/provenance-io/explorer-service/pull/558) * Updates to asset pricing table will set data column to null [#562](https://github.com/provenance-io/explorer-service/pull/562) +* Remove `running_count` and `total_count` columns from the `missed_blocks` table [#549](https://github.com/provenance-io/explorer-service/issues/549) ### Bug Fixes diff --git a/database/src/main/resources/db/migration/V1_93__Remove_columns_from_missed_block_table.sql b/database/src/main/resources/db/migration/V1_93__Remove_columns_from_missed_block_table.sql new file mode 100644 index 00000000..d308fc31 --- /dev/null +++ b/database/src/main/resources/db/migration/V1_93__Remove_columns_from_missed_block_table.sql @@ -0,0 +1,7 @@ +SELECT 'Remove running_count and total_count columns from the missed_blocks table' AS comment; + +DROP INDEX IF EXISTS missed_blocks_running_count_idx; + +ALTER TABLE missed_blocks +DROP COLUMN IF EXISTS running_count, +DROP COLUMN IF EXISTS total_count; \ No newline at end of file diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt index ec643c66..c2b097a3 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt @@ -53,7 +53,6 @@ import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insertIgnore import org.jetbrains.exposed.sql.jodatime.DateColumnType import org.jetbrains.exposed.sql.jodatime.datetime -import org.jetbrains.exposed.sql.leftJoin import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.sum @@ -205,24 +204,6 @@ class BlockProposerRecord(id: EntityID) : IntEntity(id) { it.getBigDecimal("avg_block_creation_time") }.firstOrNull() ?: BigDecimal.ZERO } - - fun findMissingRecords(min: Int, max: Int, limit: Int) = transaction { - BlockCacheTable - .leftJoin(BlockProposerTable, { BlockCacheTable.height }, { BlockProposerTable.blockHeight }) - .slice(BlockCacheTable.columns) - .select { (BlockProposerTable.blockHeight.isNull()) and (BlockCacheTable.height.between(min, max)) } - .orderBy(BlockCacheTable.height, SortOrder.ASC) - .limit(limit) - .let { BlockCacheRecord.wrapRows(it).toSet() } - } - - fun getRecordsForProposer(address: String, limit: Int) = transaction { - BlockProposerRecord.find { - (BlockProposerTable.proposerOperatorAddress eq address) - }.orderBy(Pair(BlockProposerTable.blockHeight, SortOrder.DESC)) - .limit(limit) - .toList() - } } var blockHeight by BlockProposerTable.blockHeight @@ -233,8 +214,6 @@ class BlockProposerRecord(id: EntityID) : IntEntity(id) { object MissedBlocksTable : IntIdTable(name = "missed_blocks") { val blockHeight = integer("block_height") val valConsAddr = varchar("val_cons_address", 128) - val runningCount = integer("running_count") - val totalCount = integer("total_count") } class MissedBlocksRecord(id: EntityID) : IntEntity(id) { @@ -271,17 +250,12 @@ class MissedBlocksRecord(id: EntityID) : IntEntity(id) { MissedBlocksTable.insertIgnore { it[this.blockHeight] = height it[this.valConsAddr] = valconsAddr - // TODO: remove these column from database See: https://github.com/provenance-io/explorer-service/issues/549 - it[this.runningCount] = -1 - it[this.totalCount] = -1 } } } var blockHeight by MissedBlocksTable.blockHeight var valConsAddr by MissedBlocksTable.valConsAddr - var runningCount by MissedBlocksTable.runningCount - var totalCount by MissedBlocksTable.totalCount } object BlockCacheHourlyTxCountsTable : IdTable(name = "block_cache_hourly_tx_counts") {