Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Aug 23, 2024
1 parent 758a457 commit 3ba3eef
Showing 1 changed file with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class BlockProposerRecord(id: EntityID<Int>) : IntEntity(id) {
fun getRecordsForProposer(address: String, limit: Int) = transaction {
BlockProposerRecord.find {
(BlockProposerTable.proposerOperatorAddress eq address) and
(BlockProposerTable.blockLatency.isNotNull())
(BlockProposerTable.blockLatency.isNotNull())

Check failure on line 216 in service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (24) (should be 20)
}.orderBy(Pair(BlockProposerTable.blockHeight, SortOrder.DESC))
.limit(limit)
.toList()
Expand Down Expand Up @@ -353,13 +353,14 @@ class BlockCacheHourlyTxCountsRecord(id: EntityID<DateTime>) : Entity<DateTime>(
BlockCacheHourlyTxCountsTable.slice(txSum).selectAll().map { it[txSum] }.first()!!
}

fun getTxCountsForParams(fromDate: DateTime, toDate: DateTime, granularity: DateTruncGranularity) = transaction {
when (granularity) {
DAY, MONTH -> getGranularityCounts(fromDate, toDate, granularity)
HOUR -> getHourlyCounts(fromDate, toDate)
MINUTE -> emptyList()
fun getTxCountsForParams(fromDate: DateTime, toDate: DateTime, granularity: DateTruncGranularity) =
transaction {
when (granularity) {
DAY, MONTH -> getGranularityCounts(fromDate, toDate, granularity)
HOUR -> getHourlyCounts(fromDate, toDate)
MINUTE -> emptyList()
}
}
}

fun getTxHeatmap(fromDate: DateTime? = null, toDate: DateTime? = null) = transaction {
val blockTimestamp = BlockCacheHourlyTxCountsTable.blockTimestamp
Expand Down Expand Up @@ -399,22 +400,23 @@ class BlockCacheHourlyTxCountsRecord(id: EntityID<DateTime>) : Entity<DateTime>(
TxHeatmapRes(result, dayTotals, hourTotals)
}

private fun getGranularityCounts(fromDate: DateTime, toDate: DateTime, granularity: DateTruncGranularity) = transaction {
val dateTrunc = DateTrunc(granularity.name, BlockCacheHourlyTxCountsTable.blockTimestamp)
val txSum = BlockCacheHourlyTxCountsTable.txCount.sum()
BlockCacheHourlyTxCountsTable.slice(dateTrunc, txSum)
.select {
dateTrunc.between(fromDate.startOfDay(), toDate.startOfDay())
}
.groupBy(dateTrunc)
.orderBy(dateTrunc, SortOrder.DESC)
.map {
TxHistory(
it[dateTrunc]!!.withZone(DateTimeZone.UTC).toString("yyyy-MM-dd HH:mm:ss"),
it[txSum]!!
)
}
}
private fun getGranularityCounts(fromDate: DateTime, toDate: DateTime, granularity: DateTruncGranularity) =
transaction {
val dateTrunc = DateTrunc(granularity.name, BlockCacheHourlyTxCountsTable.blockTimestamp)
val txSum = BlockCacheHourlyTxCountsTable.txCount.sum()
BlockCacheHourlyTxCountsTable.slice(dateTrunc, txSum)
.select {
dateTrunc.between(fromDate.startOfDay(), toDate.startOfDay())
}
.groupBy(dateTrunc)
.orderBy(dateTrunc, SortOrder.DESC)
.map {
TxHistory(
it[dateTrunc]!!.withZone(DateTimeZone.UTC).toString("yyyy-MM-dd HH:mm:ss"),
it[txSum]!!
)
}
}

private fun getHourlyCounts(fromDate: DateTime, toDate: DateTime) = transaction {
BlockCacheHourlyTxCountsRecord.find {
Expand Down Expand Up @@ -536,7 +538,7 @@ class BlockTxRetryRecord(id: EntityID<Int>) : IntEntity(id) {
it[this.success] = false
it[this.errorBlock] =
"NON BLOCKING ERROR: Logged to know what happened, but didnt stop processing.\n " +
e.stackTraceToString()
e.stackTraceToString()

Check failure on line 541 in service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (28) (should be 20)
}
}

Expand All @@ -545,7 +547,7 @@ class BlockTxRetryRecord(id: EntityID<Int>) : IntEntity(id) {
it[this.height] = height
it[this.errorBlock] =
"NON BLOCKING ERROR: Logged to know what happened, but didnt stop processing.\n " +
e.stackTraceToString()
e.stackTraceToString()

Check failure on line 550 in service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (28) (should be 20)
}
}

Expand All @@ -571,8 +573,8 @@ class BlockTxRetryRecord(id: EntityID<Int>) : IntEntity(id) {
BlockTxRetryTable
.deleteWhere {
(BlockTxRetryTable.retried eq true) and
(BlockTxRetryTable.success eq true) and
(BlockTxRetryTable.height inList heights)
(BlockTxRetryTable.success eq true) and

Check failure on line 576 in service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (28) (should be 24)
(BlockTxRetryTable.height inList heights)

Check failure on line 577 in service/src/main/kotlin/io/provenance/explorer/domain/entities/Blocks.kt

View workflow job for this annotation

GitHub Actions / ktlint

Unexpected indentation (28) (should be 24)
}
}
}
Expand Down Expand Up @@ -648,4 +650,4 @@ class TxProcessingFailureRecord(id: EntityID<Int>) : IntEntity(id) {
var errorMessage by TxProcessingFailuresTable.errorMessage
var retried by TxProcessingFailuresTable.retried
var success by TxProcessingFailuresTable.success
}
}

0 comments on commit 3ba3eef

Please sign in to comment.