From da58cb63b5e10960692347f777a69c0720231113 Mon Sep 17 00:00:00 2001 From: Software Magico Date: Tue, 7 May 2024 12:29:53 +0200 Subject: [PATCH] Fixed NPE --- README.md | 2 +- .../kt/core/score/ScoreOfCompetitor.java | 18 ++++++++++-------- .../tournament-statistics.component.ts | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4c6a1f230..45212e916 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager) [![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager) [![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager) -[![Time](https://img.shields.io/badge/development-605.5h-blueviolet.svg)]() +[![Time](https://img.shields.io/badge/development-606h-blueviolet.svg)]() [![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]() [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend) diff --git a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/score/ScoreOfCompetitor.java b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/score/ScoreOfCompetitor.java index 70f452b2b..4664e4063 100644 --- a/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/score/ScoreOfCompetitor.java +++ b/backend/kendo-tournament-core/src/main/java/com/softwaremagico/kt/core/score/ScoreOfCompetitor.java @@ -107,7 +107,7 @@ public void setCompetitor(Participant competitor) { public void setDuelsDone() { duelsDone = 0; fights.forEach(fight -> { - if (fight.isOver() || countNotOver) { + if ((fight != null && fight.isOver()) || (fight != null && countNotOver)) { duelsDone += fight.getDuels(competitor).size(); } }); @@ -116,7 +116,7 @@ public void setDuelsDone() { public void setDuelsWon() { wonDuels = 0; fights.forEach(fight -> { - if (fight.isOver() || countNotOver) { + if ((fight != null && fight.isOver()) || (fight != null && countNotOver)) { wonDuels += fight.getDuelsWon(competitor); } }); @@ -125,7 +125,7 @@ public void setDuelsWon() { public void setFightsWon() { wonFights = 0; for (final Fight fight : fights) { - if (fight.isOver() || countNotOver) { + if ((fight != null && fight.isOver()) || (fight != null && countNotOver)) { if (fight.isWon(competitor)) { wonFights++; } @@ -136,7 +136,7 @@ public void setFightsWon() { public void setFightsDraw() { drawFights = 0; for (final Fight fight : fights) { - if (fight.isOver() || countNotOver) { + if ((fight != null && fight.isOver()) || (fight != null && countNotOver)) { if (fight.getWinner() == null && (fight.getTeam1().isMember(competitor) || fight.getTeam2().isMember(competitor))) { drawFights++; @@ -148,8 +148,8 @@ public void setFightsDraw() { public void setTotalFights() { totalFights = 0; for (final Fight fight : fights) { - if (fight.isOver() && fight.getTeam1().isMember(competitor) - || fight.getTeam2().isMember(competitor)) { + if ((fight != null && fight.isOver() && fight.getTeam1().isMember(competitor)) + || (fight != null && fight.getTeam2().isMember(competitor))) { totalFights++; } } @@ -158,7 +158,7 @@ public void setTotalFights() { public void setDuelsDraw() { drawDuels = 0; for (final Fight fight : fights) { - if (fight.isOver() || countNotOver) { + if ((fight != null && fight.isOver()) || (fight != null && countNotOver)) { drawDuels += fight.getDrawDuels(competitor); } } @@ -167,7 +167,9 @@ public void setDuelsDraw() { public void setHits() { hits = 0; for (final Fight fight : fights) { - hits += fight.getScore(competitor); + if (fight != null) { + hits += fight.getScore(competitor); + } } } diff --git a/frontend/src/app/views/tournament-statistics/tournament-statistics.component.ts b/frontend/src/app/views/tournament-statistics/tournament-statistics.component.ts index 245d37eba..d93702a20 100644 --- a/frontend/src/app/views/tournament-statistics/tournament-statistics.component.ts +++ b/frontend/src/app/views/tournament-statistics/tournament-statistics.component.ts @@ -45,7 +45,6 @@ export class TournamentStatisticsComponent extends RbacBasedComponent implements public teamSizeByTournament: LineChartData = new LineChartData(); public participantsByTournament: StackedBarChartData = new StackedBarChartData(); public hitsByTournament: StackedBarChartData = new StackedBarChartData(); - public hitsByTournamentPercentage: StackedBarChartData = new StackedBarChartData(); public fightsOverData: GaugeChartData; private readonly tournamentId: number | undefined;