diff --git a/spa/src/AggregatesShowcase.js b/spa/src/AggregatesShowcase.js
index 79a78be..3542e29 100644
--- a/spa/src/AggregatesShowcase.js
+++ b/spa/src/AggregatesShowcase.js
@@ -2,59 +2,43 @@ import React from "react";
import { useQuery } from "react-query";
import axios from "axios";
-import {
- AspectRatio,
- Box,
- Flex,
- Heading,
- HStack,
- Icon,
- SimpleGrid,
- Stat,
- StatLabel,
- StatNumber,
- StatHelpText,
- StatArrow,
- StatGroup,
- Tooltip,
-} from "@chakra-ui/react";
-import { FaUserCircle, FaArrowAltCircleRight } from "react-icons/fa";
-import { Link } from "react-router-dom";
-import { AutoSizer, WindowScroller, List } from "react-virtualized";
+import { SimpleGrid, Stat, StatLabel, StatNumber } from "@chakra-ui/react";
import prettifyStatisticName from "./PrettifyStatisticName";
import StackedBar from "./StackedBar";
const AggregatesShowcase = () => {
- const aggregates = useQuery(
- `aggregates`,
- async () => {
- const { data } = await axios.get(`/api/aggregates`);
- return data;
- },
- {
- placeholderData: [],
- }
- );
+ const aggregates = useQuery(`aggregates`, async () => {
+ const { data } = await axios.get(`/api/aggregates`);
+ return data;
+ });
- const killedAggregates = aggregates.data
- .filter((x) => x.type === "minecraft:killed")
- .sort((a, b) => b.value - a.value);
- const killedTotal = killedAggregates.reduce((acc, val) => acc + val.value, 0);
+ const killedAggregates = aggregates.isSuccess
+ ? aggregates.data
+ .filter((x) => x.type === "minecraft:killed")
+ .sort((a, b) => b.value - a.value)
+ : [];
+ // const killedTotal = killedAggregates.reduce((acc, val) => acc + val.value, 0);
- const killedByAggregates = aggregates.data
- .filter((x) => x.type === "minecraft:killed_by")
- .sort((a, b) => b.value - a.value);
- const killedByTotal = killedByAggregates.reduce(
- (acc, val) => acc + val.value,
- 0
- );
+ const killedByAggregates = aggregates.isSuccess
+ ? aggregates.data
+ .filter((x) => x.type === "minecraft:killed_by")
+ .sort((a, b) => b.value - a.value)
+ : [];
+ // const killedByTotal = killedByAggregates.reduce(
+ // (acc, val) => acc + val.value,
+ // 0
+ // );
- const travelAggregates = aggregates.data
- .filter((x) => x.type === "minecraft:custom" && x.name.endsWith("one_cm"))
- .sort((a, b) => b.value - a.value);
- const travelTotal = travelAggregates.reduce((acc, val) => acc + val.value, 0);
+ const travelAggregates = aggregates.isSuccess
+ ? aggregates.data
+ .filter(
+ (x) => x.type === "minecraft:custom" && x.name.endsWith("one_cm")
+ )
+ .sort((a, b) => b.value - a.value)
+ : [];
+ // const travelTotal = travelAggregates.reduce((acc, val) => acc + val.value, 0);
- return aggregates.isFetched ? (
+ return aggregates.isSuccess ? (
<>
@@ -73,13 +57,13 @@ const AggregatesShowcase = () => {
.map((x, i) => {
var value = x.value;
if (x.name === "minecraft:play_one_minute") {
- value = x.value / 20 / 60;
+ value = Math.floor(x.value / 20 / 60);
}
return (
{prettifyStatisticName(x.type, x.name)}
- {`${x.value
+ {`${value
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`}