Skip to content

Commit

Permalink
Added SortOrder, smart move to better code and save life... I fargot …
Browse files Browse the repository at this point in the history
…this usefull function.
  • Loading branch information
EncryptSL committed Apr 5, 2024
1 parent 9083ccd commit dde167a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class DatabaseEcoModel : PlayerSQLProvider {
}

override fun getTopBalance(top: Int): MutableMap<String, Double> = loggedTransaction {
Account.selectAll().limit(top).associate {
Account.selectAll().limit(top).orderBy(Account.money, SortOrder.DESC).associate {
it[Account.uuid] to it[Account.money]
}.toMutableMap()
}

override fun getTopBalance(): MutableMap<String, Double> = loggedTransaction {
Account.selectAll().associate {
Account.selectAll().orderBy(Account.money, SortOrder.DESC).associate {
it[Account.uuid] to it[Account.money]
}.toMutableMap()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.github.encryptsl.lite.eco.common.database.entity.EconomyLog
import com.github.encryptsl.lite.eco.common.database.tables.MonologTable
import com.github.encryptsl.lite.eco.common.extensions.loggedTransaction
import org.bukkit.plugin.Plugin
import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.deleteAll
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.selectAll
Expand All @@ -28,7 +29,7 @@ class DatabaseMonologModel(val plugin: Plugin) : AdapterLogger {
}

override fun getLog(): List<EconomyLog> {
val query = loggedTransaction { MonologTable.selectAll() }
val query = loggedTransaction { MonologTable.selectAll().orderBy(MonologTable.timestamp, SortOrder.DESC) }
return query.mapNotNull { EconomyLog(it[MonologTable.level], it[MonologTable.log], it[MonologTable.timestamp]) }
}

Expand Down

0 comments on commit dde167a

Please sign in to comment.