Skip to content

Commit

Permalink
Do not store the enum name, store the enum ordinal for the LorittaDis…
Browse files Browse the repository at this point in the history
…cordShardStats, add cluster id
  • Loading branch information
MrPowerGamerBR committed Oct 19, 2024
1 parent a43be45 commit f82431c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MagicStats(val loritta: LorittaBot) : RunnableCoroutine {
it[TotalSonhosStats.totalSonhosBroker] = totalSonhosBroker
}
}

val mb = 1024 * 1024
val runtime = Runtime.getRuntime()
val freeMemory = runtime.freeMemory() / mb
Expand All @@ -82,9 +82,10 @@ class MagicStats(val loritta: LorittaBot) : RunnableCoroutine {
val shardManager = loritta.lorittaShards.shardManager
LorittaDiscordShardStats.batchInsert(shardManager.shardCache, shouldReturnGeneratedValues = false) {
this[LorittaDiscordShardStats.timestamp] = now
this[LorittaDiscordShardStats.clusterId] = loritta.clusterId
this[LorittaDiscordShardStats.shardId] = it.shardInfo.shardId
this[LorittaDiscordShardStats.status] = it.status.name
this[LorittaDiscordShardStats.gatewayStartupResumeStatus] = loritta.gatewayShardsStartupResumeStatus[it.shardInfo.shardId]?.name
this[LorittaDiscordShardStats.status] = it.status.ordinal
this[LorittaDiscordShardStats.gatewayStartupResumeStatus] = loritta.gatewayShardsStartupResumeStatus[it.shardInfo.shardId]?.ordinal
this[LorittaDiscordShardStats.gatewayPing] = it.gatewayPing
this[LorittaDiscordShardStats.responseTotal] = it.responseTotal
this[LorittaDiscordShardStats.guildsCount] = it.guildCache.size()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Pudding(
private val DRIVER_CLASS_NAME = "org.postgresql.Driver"
private val ISOLATION_LEVEL =
IsolationLevel.TRANSACTION_REPEATABLE_READ // We use repeatable read to avoid dirty and non-repeatable reads! Very useful and safe!!
private const val SCHEMA_VERSION = 64 // Bump this every time any table is added/updated!
private const val SCHEMA_VERSION = 65 // Bump this every time any table is added/updated!
private val SCHEMA_ID = UUID.fromString("600556aa-2920-41c7-b26c-7717eff2d392") // This is a random unique ID, it is used for upserting the schema version

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import org.jetbrains.exposed.dao.id.LongIdTable

object LorittaDiscordShardStats : LongIdTable() {
val timestamp = timestampWithTimeZone("timestamp").index()
val clusterId = integer("cluster_id").index()
val shardId = integer("shard_id").index()
val status = text("status")
val gatewayStartupResumeStatus = text("gateway_startup_resume_status").nullable()
// We don't use enumerations because we don't have access to JDA.Status nor the GW Startup Resume Status here
// And we can't use text because they are BIG and FAT
val status = integer("status")
val gatewayStartupResumeStatus = integer("gateway_startup_resume_status").nullable()
val gatewayPing = long("gateway_ping")
val responseTotal = long("response_total")
val guildsCount = long("guild_count")
Expand Down

0 comments on commit f82431c

Please sign in to comment.