Fix aggregates calculations
parent
959ac79fbd
commit
a86453f497
|
@ -65,8 +65,6 @@ object StatisticsImporter {
|
|||
}
|
||||
}
|
||||
transaction(database) {
|
||||
addLogger(StdOutSqlLogger)
|
||||
|
||||
statsFile?.stats?.forEach { type, stats ->
|
||||
stats.forEach { name, value ->
|
||||
if (playerStats.get(type)?.get(name) != value) {
|
||||
|
@ -134,29 +132,41 @@ object StatisticsImporter {
|
|||
SET @Timestamp = CURRENT_TIMESTAMP;
|
||||
|
||||
INSERT INTO AGGREGATESTATISTICS ("Type", "Name", "Timestamp", "Value")
|
||||
SELECT Live."Type",
|
||||
SELECT LiveMax."Type",
|
||||
'',
|
||||
@Timestamp AS "Timestamp",
|
||||
sum(Live."Value")
|
||||
FROM LIVESTATISTICS as Live
|
||||
SUM(LiveMax."Value")
|
||||
FROM (
|
||||
SELECT Live."Type",
|
||||
Live."Name",
|
||||
MAX(Live."Value") AS "Value"
|
||||
FROM livestatistics as Live
|
||||
WHERE array_contains(array['minecraft:mined'], Live."Type")
|
||||
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
||||
) as LiveMax
|
||||
LEFT JOIN AGGREGATESTATISTICS as Agg
|
||||
ON Live."Type" = Agg."Type"
|
||||
WHERE array_contains(array['minecraft:mined'], Live."Type")
|
||||
GROUP BY Live."Type"
|
||||
HAVING sum(Live."Value") <> max(Agg."Value") OR max(Agg."Value") IS NULL;
|
||||
|
||||
INSERT INTO AGGREGATESTATISTICS ("Type", "Name", "Timestamp", "Value")
|
||||
SELECT LiveMax."Type",
|
||||
LiveMax."Name",
|
||||
@Timestamp AS "Timestamp",
|
||||
SUM(LiveMax."Value")
|
||||
FROM (
|
||||
SELECT Live."Type",
|
||||
Live."Name",
|
||||
@Timestamp AS "Timestamp",
|
||||
Sum(Live."Value")
|
||||
MAX(Live."Value") AS "Value"
|
||||
FROM livestatistics as Live
|
||||
LEFT JOIN AGGREGATESTATISTICS as Agg
|
||||
ON Live."Type" = Agg."Type" AND Live."Name" = Agg."Name"
|
||||
WHERE array_contains(array['minecraft:animals_bred', 'minecraft:play_one_minute', 'minecraft:deaths', 'minecraft:player_kills', 'minecraft:aviate_one_cm', 'minecraft:boat_one_cm', 'minecraft:crouch_one_cm', 'minecraft:horse_one_cm', 'minecraft:minecart_one_cm', 'minecraft:sprint_one_cm', 'minecraft:strider_one_cm', 'minecraft:swim_one_cm', 'minecraft:walk_on_water_one_cm', 'minecraft:walk_one_cm', 'minecraft:walk_under_water_one_cm' ], Live."Name")
|
||||
OR array_contains(array['minecraft:killed', 'minecraft:killed_by'], Live."Type")
|
||||
GROUP BY Live."Type", Live."Name"
|
||||
HAVING sum(Live."Value") <> max(Agg."Value") OR max(Agg."Value") IS NULL;
|
||||
OR array_contains(array['minecraft:killed', 'minecraft:killed_by'], Live."Type")
|
||||
GROUP BY Live."Type", Live."Name", Live."PlayerId"
|
||||
) as LiveMax
|
||||
LEFT JOIN AGGREGATESTATISTICS as Agg
|
||||
ON LiveMax."Type" = Agg."Type" AND LiveMax."Name" = Agg."Name"
|
||||
GROUP BY LiveMax."Type", LiveMax."Name"
|
||||
HAVING SUM(LiveMax."Value") <> MAX(Agg."Value") OR MAX(Agg."Value") IS NULL;
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue