forked from Minecraft/Stonks
parent
6b3f87c401
commit
8e27e95fd9
|
@ -134,6 +134,14 @@ fun initH2Server(
|
||||||
it[KeyValue.value] = 1
|
it[KeyValue.value] = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schemaVersion < 2) {
|
||||||
|
println("Migrating database to schemaVersion 2.")
|
||||||
|
|
||||||
|
TransactionManager.current().exec("TRUNCATE TABLE AGGREGATESTATISTICS")
|
||||||
|
|
||||||
|
KeyValue.update({ KeyValue.key eq "SchemaVersion" }) { it[KeyValue.value] = 2 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return database
|
return database
|
||||||
|
|
|
@ -144,7 +144,13 @@ object StatisticsImporter {
|
||||||
WHERE array_contains(array['minecraft:mined'], Live."Type")
|
WHERE array_contains(array['minecraft:mined'], Live."Type")
|
||||||
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
||||||
) as LiveMax
|
) as LiveMax
|
||||||
LEFT JOIN AGGREGATESTATISTICS as Agg
|
LEFT JOIN (
|
||||||
|
SELECT AGGREGATESTATISTICS."Type",
|
||||||
|
AGGREGATESTATISTICS."Name",
|
||||||
|
MAX(AGGREGATESTATISTICS."Value") as "Value"
|
||||||
|
FROM AGGREGATESTATISTICS
|
||||||
|
GROUP BY AGGREGATESTATISTICS."Type", AGGREGATESTATISTICS."Name"
|
||||||
|
) as Agg
|
||||||
ON LiveMax."Type" = Agg."Type"
|
ON LiveMax."Type" = Agg."Type"
|
||||||
GROUP BY LiveMax."Type"
|
GROUP BY LiveMax."Type"
|
||||||
HAVING sum(LiveMax."Value") <> max(Agg."Value") OR max(Agg."Value") IS NULL;
|
HAVING sum(LiveMax."Value") <> max(Agg."Value") OR max(Agg."Value") IS NULL;
|
||||||
|
@ -163,7 +169,13 @@ object StatisticsImporter {
|
||||||
OR array_contains(array['minecraft:killed', 'minecraft:killed_by'], Live."Type")
|
OR array_contains(array['minecraft:killed', 'minecraft:killed_by'], Live."Type")
|
||||||
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
||||||
) as LiveMax
|
) as LiveMax
|
||||||
LEFT JOIN AGGREGATESTATISTICS as Agg
|
LEFT JOIN (
|
||||||
|
SELECT AGGREGATESTATISTICS."Type",
|
||||||
|
AGGREGATESTATISTICS."Name",
|
||||||
|
MAX(AGGREGATESTATISTICS."Value") as "Value"
|
||||||
|
FROM AGGREGATESTATISTICS
|
||||||
|
GROUP BY AGGREGATESTATISTICS."Type", AGGREGATESTATISTICS."Name"
|
||||||
|
) as Agg
|
||||||
ON LiveMax."Type" = Agg."Type" AND LiveMax."Name" = Agg."Name"
|
ON LiveMax."Type" = Agg."Type" AND LiveMax."Name" = Agg."Name"
|
||||||
GROUP BY LiveMax."Type", LiveMax."Name"
|
GROUP BY LiveMax."Type", LiveMax."Name"
|
||||||
HAVING SUM(LiveMax."Value") <> MAX(Agg."Value") OR MAX(Agg."Value") IS NULL;
|
HAVING SUM(LiveMax."Value") <> MAX(Agg."Value") OR MAX(Agg."Value") IS NULL;
|
||||||
|
|
Loading…
Reference in New Issue