aboutsummaryrefslogtreecommitdiff
path: root/server/analysis/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-22 01:42:48 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-22 01:42:48 +0100
commit5a49c878ede9df81417c79e98d226c941551f3c0 (patch)
tree18e00d481aa4e3cbbb6750a73256f7fadf96e915 /server/analysis/src
parent0b760977102a05edd8f23cbaa9d6dcf042fede43 (diff)
downloadLocalTransactionLedger-5a49c878ede9df81417c79e98d226c941551f3c0.tar.gz
LocalTransactionLedger-5a49c878ede9df81417c79e98d226c941551f3c0.tar.bz2
LocalTransactionLedger-5a49c878ede9df81417c79e98d226c941551f3c0.zip
refactor: Allow accessing typed operands more easily
Diffstat (limited to 'server/analysis/src')
-rw-r--r--server/analysis/src/main/kotlin/moe/nea/ledger/analysis/AnalysisFilter.kt5
-rw-r--r--server/analysis/src/main/kotlin/moe/nea/ledger/analysis/CoinsSpentOnAuctions.kt12
2 files changed, 6 insertions, 11 deletions
diff --git a/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/AnalysisFilter.kt b/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/AnalysisFilter.kt
index b9178cc..9df2ce3 100644
--- a/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/AnalysisFilter.kt
+++ b/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/AnalysisFilter.kt
@@ -2,6 +2,7 @@ package moe.nea.ledger.analysis
import moe.nea.ledger.database.DBLogEntry
import moe.nea.ledger.database.Query
+import moe.nea.ledger.database.columns.DBUlid
import moe.nea.ledger.database.sql.Clause
import moe.nea.ledger.utils.ULIDWrapper
import java.time.Instant
@@ -10,8 +11,8 @@ import java.util.UUID
interface AnalysisFilter {
fun applyTo(query: Query) {
- query.where(Clause { column(DBLogEntry.transactionId) ge string(ULIDWrapper.lowerBound(startWindow).wrapped) })
- .where(Clause { column(DBLogEntry.transactionId) le string(ULIDWrapper.upperBound(endWindow).wrapped) })
+ query.where(Clause { column(DBLogEntry.transactionId) ge value(DBUlid, ULIDWrapper.lowerBound(startWindow)) })
+ .where(Clause { column(DBLogEntry.transactionId) le value(DBUlid, ULIDWrapper.upperBound(endWindow)) })
// TODO: apply profiles filter
}
diff --git a/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/CoinsSpentOnAuctions.kt b/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/CoinsSpentOnAuctions.kt
index 5e2e633..d1ce52b 100644
--- a/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/CoinsSpentOnAuctions.kt
+++ b/server/analysis/src/main/kotlin/moe/nea/ledger/analysis/CoinsSpentOnAuctions.kt
@@ -20,15 +20,9 @@ class CoinsSpentOnAuctions : Analysis {
override fun perform(database: Connection, filter: AnalysisFilter): AnalysisResult {
val query = DBLogEntry.from(database)
.join(DBItemEntry, Clause { column(DBItemEntry.transactionId) eq column(DBLogEntry.transactionId) })
- .where(Clause {
- (column(DBItemEntry.itemId) eq string(ItemId.COINS.string))
- })
- .where(Clause {
- (column(DBItemEntry.mode) eq string(ItemChange.ChangeDirection.LOST.name))
- })
- .where(Clause {
- (column(DBLogEntry.type) eq string(TransactionType.AUCTION_BOUGHT.name))
- })
+ .where(Clause { column(DBItemEntry.itemId) eq ItemId.COINS })
+ .where(Clause { column(DBItemEntry.mode) eq ItemChange.ChangeDirection.LOST })
+ .where(Clause { column(DBLogEntry.type) eq TransactionType.AUCTION_BOUGHT })
.select(DBItemEntry.size, DBLogEntry.transactionId)
filter.applyTo(query)
val spentThatDay = mutableMapOf<LocalDate, Double>()