Skip to content

Commit 061f488

Browse files
Remove running_count and total_count columns from the missed_blocks table (#564)
* remove column properties from table identity * remove unused query methods * add flyway drop column script * add change log entry * fix lint
1 parent e696de8 commit 061f488

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4848
* Remove spotlight from caching to the database [#532](https://github.com/provenance-io/explorer-service/issues/532)
4949
* Update keep alive times for flow api grpc calls [#558](https://github.com/provenance-io/explorer-service/pull/558)
5050
* Updates to asset pricing table will set data column to null [#562](https://github.com/provenance-io/explorer-service/pull/562)
51+
* Remove `running_count` and `total_count` columns from the `missed_blocks` table [#549](https://github.com/provenance-io/explorer-service/issues/549)
5152

5253
### Bug Fixes
5354

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT 'Remove running_count and total_count columns from the missed_blocks table' AS comment;
2+
3+
DROP INDEX IF EXISTS missed_blocks_running_count_idx;
4+
5+
ALTER TABLE missed_blocks
6+
DROP COLUMN IF EXISTS running_count,
7+
DROP COLUMN IF EXISTS total_count;

service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

-26
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import org.jetbrains.exposed.sql.deleteWhere
5353
import org.jetbrains.exposed.sql.insertIgnore
5454
import org.jetbrains.exposed.sql.jodatime.DateColumnType
5555
import org.jetbrains.exposed.sql.jodatime.datetime
56-
import org.jetbrains.exposed.sql.leftJoin
5756
import org.jetbrains.exposed.sql.select
5857
import org.jetbrains.exposed.sql.selectAll
5958
import org.jetbrains.exposed.sql.sum
@@ -205,24 +204,6 @@ class BlockProposerRecord(id: EntityID<Int>) : IntEntity(id) {
205204
it.getBigDecimal("avg_block_creation_time")
206205
}.firstOrNull() ?: BigDecimal.ZERO
207206
}
208-
209-
fun findMissingRecords(min: Int, max: Int, limit: Int) = transaction {
210-
BlockCacheTable
211-
.leftJoin(BlockProposerTable, { BlockCacheTable.height }, { BlockProposerTable.blockHeight })
212-
.slice(BlockCacheTable.columns)
213-
.select { (BlockProposerTable.blockHeight.isNull()) and (BlockCacheTable.height.between(min, max)) }
214-
.orderBy(BlockCacheTable.height, SortOrder.ASC)
215-
.limit(limit)
216-
.let { BlockCacheRecord.wrapRows(it).toSet() }
217-
}
218-
219-
fun getRecordsForProposer(address: String, limit: Int) = transaction {
220-
BlockProposerRecord.find {
221-
(BlockProposerTable.proposerOperatorAddress eq address)
222-
}.orderBy(Pair(BlockProposerTable.blockHeight, SortOrder.DESC))
223-
.limit(limit)
224-
.toList()
225-
}
226207
}
227208

228209
var blockHeight by BlockProposerTable.blockHeight
@@ -233,8 +214,6 @@ class BlockProposerRecord(id: EntityID<Int>) : IntEntity(id) {
233214
object MissedBlocksTable : IntIdTable(name = "missed_blocks") {
234215
val blockHeight = integer("block_height")
235216
val valConsAddr = varchar("val_cons_address", 128)
236-
val runningCount = integer("running_count")
237-
val totalCount = integer("total_count")
238217
}
239218

240219
class MissedBlocksRecord(id: EntityID<Int>) : IntEntity(id) {
@@ -271,17 +250,12 @@ class MissedBlocksRecord(id: EntityID<Int>) : IntEntity(id) {
271250
MissedBlocksTable.insertIgnore {
272251
it[this.blockHeight] = height
273252
it[this.valConsAddr] = valconsAddr
274-
// TODO: remove these column from database See: https://github.com/provenance-io/explorer-service/issues/549
275-
it[this.runningCount] = -1
276-
it[this.totalCount] = -1
277253
}
278254
}
279255
}
280256

281257
var blockHeight by MissedBlocksTable.blockHeight
282258
var valConsAddr by MissedBlocksTable.valConsAddr
283-
var runningCount by MissedBlocksTable.runningCount
284-
var totalCount by MissedBlocksTable.totalCount
285259
}
286260

287261
object BlockCacheHourlyTxCountsTable : IdTable<DateTime>(name = "block_cache_hourly_tx_counts") {

0 commit comments

Comments
 (0)