Skip to content

Commit

Permalink
Merge pull request #50 from PaulKreft/small-fixes
Browse files Browse the repository at this point in the history
fix average time stat display (again)
  • Loading branch information
PaulKreft authored Feb 26, 2024
2 parents 98d3457 + a6fa797 commit 250d406
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private ScoreMap getAverageDurations(List<Game> easyGames, List<Game> mediumGame
List<Double> hardDurations = hardGames.stream().map(game -> Double.valueOf(game.duration())).filter(d -> d != 0).toList();

Double averageDurationEasy = !easyDurations.isEmpty() ? easyDurations.stream().mapToDouble(v -> v).sum() / easyDurations.size() : null;
Double averageDurationMedium = !mediumDurations.isEmpty() ? mediumDurations.stream().mapToDouble(v -> v).sum() / easyDurations.size() : null;
Double averageDurationHard = !hardDurations.isEmpty() ? hardDurations.stream().mapToDouble(v -> v).sum() / easyDurations.size() : null;
Double averageDurationMedium = !mediumDurations.isEmpty() ? mediumDurations.stream().mapToDouble(v -> v).sum() / mediumDurations.size() : null;
Double averageDurationHard = !hardDurations.isEmpty() ? hardDurations.stream().mapToDouble(v -> v).sum() / hardDurations.size() : null;

return new ScoreMap(averageDurationEasy, averageDurationMedium, averageDurationHard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void getUserClassicStatisticsTest_whenAllStatisticsCalculable_returnCorrectValue
new ScoreMap(12.0, 3.0, 6.0),
new ScoreMap(7.0, 2.0, 1.0),
new ScoreMap(3632.0, 8578.0, 15833.0),
new ScoreMap(6866.285714285715, 3611.0, 2261.8571428571427)
new ScoreMap(6866.285714285715, 12638.5, 15833.0)
);

// When
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { User } from "../types/User.ts";
import axios from "axios";
import { Statistics } from "../types/Statistics.ts";
import { Statistic } from "./Statistic.tsx";
import { Spinner } from "./Spinner.tsx";

type PlayProps = {
user: User;
Expand Down Expand Up @@ -36,7 +37,11 @@ export const Profile: React.FC<PlayProps> = ({ user }) => {
}, [user]);

if (user == null || !statistics) {
return <div>loading</div>;
return (
<div className="flex h-screen w-screen items-center justify-center">
<Spinner />
</div>
);
}

return (
Expand Down

0 comments on commit 250d406

Please sign in to comment.