mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-30 15:57:11 +00:00
fixed live time for getQuickRanks(); added several null checks for cases where competitors haven't started their legs yet
This commit is contained in:
1 parent
1a6663af45
commit
0dbfaba524
4 files changed
+13
-4
No files matched your search
+5
-1
@@ -161,13 +161,17 @@ public abstract class AbstractRankingMetric implements RankingMetric {
|
||||
final Duration result;
|
||||
final TrackedLegOfCompetitor tloc = getTrackedRace().getTrackedLeg(competitor, getTimePoint());
|
||||
final Duration raceDurationAtTimePoint = getTrackedRace().getStartOfRace().until(getTimePoint());
|
||||
if (tloc.hasStartedLeg(getTimePoint())) {
|
||||
if (tloc != null && tloc.hasStartedLeg(getTimePoint())) {
|
||||
final Competitor competitorFarthestAheadInLeg = getCompetitorFarthestAheadInLeg(leg, getTimePoint(), cache);
|
||||
final TrackedLegOfCompetitor tlocOfCompetitorFarthestAheadInLeg = tloc.getTrackedLeg().getTrackedLeg(competitorFarthestAheadInLeg);
|
||||
final Duration predictedDurationFromTimePointToReachFarthestAheadInLeg = getPredictedDurationToReachWindwardPositionOf(
|
||||
tloc, tlocOfCompetitorFarthestAheadInLeg, getTimePoint(), cache);
|
||||
if (predictedDurationFromTimePointToReachFarthestAheadInLeg == null) {
|
||||
result = null;
|
||||
} else {
|
||||
final Duration cDurationFromRaceStartToReachFarthestInLeg = raceDurationAtTimePoint.plus(predictedDurationFromTimePointToReachFarthestAheadInLeg);
|
||||
result = cDurationFromRaceStartToReachFarthestInLeg;
|
||||
}
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
|
||||
+4
@@ -325,6 +325,9 @@ public class TimeOnTimeAndDistanceRankingMetric extends AbstractRankingMetric {
|
||||
result = null;
|
||||
} else {
|
||||
final Competitor farthestAheadOrEarliestLegFinisher = getCompetitorFarthestAheadInLeg(trackedLegOfCompetitor.getTrackedLeg(), timePoint, cache);
|
||||
if (farthestAheadOrEarliestLegFinisher == null) {
|
||||
result = null;
|
||||
} else {
|
||||
final TrackedLegOfCompetitor tlocOfFarthestAhead = trackedLegOfCompetitor.getTrackedLeg().getTrackedLeg(farthestAheadOrEarliestLegFinisher);
|
||||
final boolean farthestAheadAlreadyFinishedLeg = tlocOfFarthestAhead.hasFinishedLeg(timePoint);
|
||||
final Distance windwardDistanceFarthestTraveledUntilFinishingLeg = getWindwardDistanceTraveled(farthestAheadOrEarliestLegFinisher,
|
||||
@@ -339,6 +342,7 @@ public class TimeOnTimeAndDistanceRankingMetric extends AbstractRankingMetric {
|
||||
rankingInfo.getActualTimeFromRaceStartToReachFarthestAheadInLeg(legLeader, leg, cache),
|
||||
windwardDistanceFarthestTraveledUntilFinishingLeg);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -2055,7 +2055,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
rank++;
|
||||
}
|
||||
final Iterable<Competitor> competitorsInOrderOfWindwardDistanceTraveledFarthestFirst = getService().getCompetitorInOrderOfWindwardDistanceTraveledFarthestFirst(trackedRace, timePoint);
|
||||
final Iterable<Competitor> competitorsInOrderOfWindwardDistanceTraveledFarthestFirst = getService()
|
||||
.getCompetitorInOrderOfWindwardDistanceTraveledFarthestFirst(trackedRace, actualTimePoint);
|
||||
competitorDTOsInOrderOfWindwardDistanceTraveledFarthestFirst = convertToCompetitorDTOs(competitorsInOrderOfWindwardDistanceTraveledFarthestFirst);
|
||||
} else {
|
||||
competitorDTOsInOrderOfWindwardDistanceTraveledFarthestFirst = Collections.emptyList();
|
||||
|
||||
+2
-2
@@ -39,6 +39,7 @@ public class CompactRaceMapDataDTO implements IsSerializable {
|
||||
this.boatPositionsByCompetitorIdAsString.put(e.getKey().getIdAsString(), e.getValue());
|
||||
}
|
||||
this.quickRanks = new ArrayList<CompactQuickRankDTO>(quickRanks == null ? 0 : Util.size(quickRanks.getQuickRanks()));
|
||||
this.competitorsInOrderOfWindwardDistanceTraveledFarthestFirstIdAsStringAndOneBasedLegNumber = new LinkedHashMap<>();
|
||||
Map<String, Integer> competitorIdAsStringToOneBasedLegNumber = new HashMap<>();
|
||||
if (quickRanks != null) {
|
||||
for (QuickRankDTO quickRank : quickRanks.getQuickRanks()) {
|
||||
@@ -46,13 +47,12 @@ public class CompactRaceMapDataDTO implements IsSerializable {
|
||||
quickRank.legNumberOneBased));
|
||||
competitorIdAsStringToOneBasedLegNumber.put(quickRank.competitor.getIdAsString(), quickRank.legNumberOneBased);
|
||||
}
|
||||
}
|
||||
this.competitorsInOrderOfWindwardDistanceTraveledFarthestFirstIdAsStringAndOneBasedLegNumber = new LinkedHashMap<>();
|
||||
for (CompetitorDTO competitorInOrderOfWindwardDistanceTraveled : quickRanks.getCompetitorsInOrderOfWindwardDistanceTraveledFarthestFirst()) {
|
||||
this.competitorsInOrderOfWindwardDistanceTraveledFarthestFirstIdAsStringAndOneBasedLegNumber.put(
|
||||
competitorInOrderOfWindwardDistanceTraveled.getIdAsString(),
|
||||
competitorIdAsStringToOneBasedLegNumber.get(competitorInOrderOfWindwardDistanceTraveled.getIdAsString()));
|
||||
}
|
||||
}
|
||||
this.courseSidelines = courseSidelines;
|
||||
this.coursePositions = coursePositions;
|
||||
this.simulationResultVersion = simulationResultVersion;
|
||||
|
||||
Reference in new issue
Block a user