Remove now unused Postgres table and log limit config options #36
No files matched your search
@@ -5,8 +5,5 @@ interface Config {
|
||||
var postgresUrl: String
|
||||
var postgresUser: String
|
||||
var postgresPassword: String
|
||||
var postgresTable: String
|
||||
var postgresLogTable: String
|
||||
var postgresLogLimit: Int
|
||||
var redisUrl: String
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"INSERT INTO ${config.postgresTable}(uuid, ${type.string}) VALUES(?, ?) ON CONFLICT (uuid) DO UPDATE SET ${type.string} = excluded.${type.string} " +
|
||||
"INSERT INTO diamond(uuid, ${type.string}) VALUES(?, ?) ON CONFLICT (uuid) DO UPDATE SET ${type.string} = excluded.${type.string} " +
|
||||
"RETURNING bank_shards, inventory_shards, ender_chest_shards",
|
||||
listOf(uuid, shards),
|
||||
)
|
||||
@@ -104,8 +104,8 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"INSERT INTO ${config.postgresTable}(uuid, ${type.string}) VALUES(?, ?) ON CONFLICT (uuid) DO UPDATE SET ${type.string} = ${config.postgresTable}.${type.string} + excluded.${type.string} " +
|
||||
"WHERE ${config.postgresTable}.${type.string} + excluded.${type.string} >= 0 RETURNING bank_shards, inventory_shards, ender_chest_shards",
|
||||
"INSERT INTO diamond(uuid, ${type.string}) VALUES(?, ?) ON CONFLICT (uuid) DO UPDATE SET ${type.string} = diamond.${type.string} + excluded.${type.string} " +
|
||||
"WHERE diamond.${type.string} + excluded.${type.string} >= 0 RETURNING bank_shards, inventory_shards, ender_chest_shards",
|
||||
listOf(uuid, shards),
|
||||
)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"SELECT total_shards FROM ${config.postgresTable} WHERE uuid = ? LIMIT 1",
|
||||
"SELECT total_shards FROM diamond WHERE uuid = ? LIMIT 1",
|
||||
listOf(uuid),
|
||||
)
|
||||
}
|
||||
@@ -184,7 +184,7 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"SELECT bank_shards, inventory_shards, ender_chest_shards FROM ${config.postgresTable} WHERE uuid = ? LIMIT 1",
|
||||
"SELECT bank_shards, inventory_shards, ender_chest_shards FROM diamond WHERE uuid = ? LIMIT 1",
|
||||
listOf(uuid),
|
||||
)
|
||||
}
|
||||
@@ -217,7 +217,7 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"SELECT ${type.string} FROM ${config.postgresTable} WHERE uuid = ? LIMIT 1",
|
||||
"SELECT ${type.string} FROM diamond WHERE uuid = ? LIMIT 1",
|
||||
listOf(uuid),
|
||||
)
|
||||
}
|
||||
@@ -246,7 +246,7 @@ class PostgreSQL private constructor() {
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"SELECT uuid, total_shards " +
|
||||
"FROM ${config.postgresTable} " +
|
||||
"FROM diamond " +
|
||||
"ORDER BY total_shards DESC, uuid DESC OFFSET ? LIMIT 9",
|
||||
listOf(offset),
|
||||
)
|
||||
@@ -280,7 +280,7 @@ class PostgreSQL private constructor() {
|
||||
"WITH ranked AS (" +
|
||||
"SELECT " +
|
||||
"uuid, total_shards, ROW_NUMBER() OVER (ORDER BY total_shards DESC, uuid DESC) AS rn " +
|
||||
"FROM ${config.postgresTable}" +
|
||||
"FROM diamond" +
|
||||
"), " +
|
||||
"target AS (" +
|
||||
"SELECT rn, ((rn - 1) / 9) * 9 AS page_offset FROM ranked WHERE uuid = ?), " +
|
||||
@@ -315,9 +315,7 @@ class PostgreSQL private constructor() {
|
||||
val connection = pool.asSuspending.connect()
|
||||
val result =
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement("SELECT count(*) AS exact_count FROM ${config.postgresTable}")
|
||||
}
|
||||
.inTransaction { conn -> conn.sendPreparedStatement("SELECT count(*) AS exact_count FROM diamond") }
|
||||
.await()
|
||||
|
||||
if (result.rows.isNotEmpty()) {
|
||||
@@ -346,7 +344,7 @@ class PostgreSQL private constructor() {
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement(
|
||||
"INSERT INTO ${config.postgresLogTable}(player_uuid, transferred_shards, player_to_uuid, transaction_reason, notes) " +
|
||||
"INSERT INTO diamond_log(player_uuid, transferred_shards, player_to_uuid, transaction_reason, notes) " +
|
||||
"VALUES(?, ?, ?, ?, ?)",
|
||||
listOf(playerUuid, transferredShards, playerToUuid, transactionReason, notes),
|
||||
)
|
||||
@@ -364,7 +362,7 @@ class PostgreSQL private constructor() {
|
||||
val result =
|
||||
connection
|
||||
.inTransaction { conn ->
|
||||
conn.sendPreparedStatement("SELECT 1 FROM ${config.postgresTable} WHERE uuid = ?", listOf(uuid))
|
||||
conn.sendPreparedStatement("SELECT 1 FROM diamond WHERE uuid = ?", listOf(uuid))
|
||||
}
|
||||
.await()
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
import net.trueog.diamondbankog.DiamondBankOG.Companion.plugin
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
|
||||
@@ -10,9 +9,6 @@ internal class YamlConfig private constructor() : Config {
|
||||
override lateinit var postgresUrl: String
|
||||
override lateinit var postgresUser: String
|
||||
override lateinit var postgresPassword: String
|
||||
override lateinit var postgresTable: String
|
||||
override lateinit var postgresLogTable: String
|
||||
override var postgresLogLimit by Delegates.notNull<Int>()
|
||||
override lateinit var redisUrl: String
|
||||
|
||||
companion object : ConfigFactory {
|
||||
@@ -50,31 +46,6 @@ internal class YamlConfig private constructor() : Config {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
config.postgresTable = yamlConfig.get("postgresTable") as String
|
||||
} catch (_: Exception) {
|
||||
plugin.logger.severe("Failed to parse config option \"postgresTable\" as a string")
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
config.postgresLogTable = yamlConfig.get("postgresLogTable") as String
|
||||
} catch (_: Exception) {
|
||||
plugin.logger.severe("Failed to parse config option \"postgresLogTable\" as a string")
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
config.postgresLogLimit = yamlConfig.get("postgresLogLimit") as Int
|
||||
if (config.postgresLogLimit < 1) {
|
||||
plugin.logger.severe("\"postgresLogLimit\" cannot be less than 1")
|
||||
return null
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
plugin.logger.severe("Failed to parse config option \"postgresLogLimit\" as an integer")
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
config.redisUrl = yamlConfig.get("redisUrl") as String
|
||||
} catch (_: Exception) {
|
||||
|
||||
@@ -6,9 +6,6 @@ prefix: <gray>[<aqua>DiamondBank<white>-<red>OG<gray>]
|
||||
postgresUrl: jdbc:postgresql://localhost:5432/diamond
|
||||
postgresUser: ^{DIAMONDBANKOG_POSTGRES_USER}
|
||||
postgresPassword: ^{DIAMONDBANKOG_POSTGRES_PASSWORD}
|
||||
postgresTable: diamond
|
||||
postgresLogTable: diamond_log
|
||||
postgresLogLimit: 1000
|
||||
|
||||
# ---Redis-compatible URI---
|
||||
# According to https://redis.github.io/lettuce/user-guide/connecting-redis/#uri-syntax
|
||||
|
||||
Reference in new issue
Block a user