fixed gap change in own time, making a distinction between first and other legs

This commit is contained in:
Axel Uhl committed 2015-05-21 08:39:02 +02:00
1 parent 378d5f48cb
commit d3073529ff
1 file changed
+12 -8
@@ -1671,7 +1671,7 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
getLegGapToLegLeaderInOwnTime(trackedLeg, timePoint, cache); getLegGapToLegLeaderInOwnTime(trackedLeg, timePoint, cache);
result.gapToLeaderInSeconds = gapToLeaderInOwnTime == null ? null : gapToLeaderInOwnTime.asSeconds(); result.gapToLeaderInSeconds = gapToLeaderInOwnTime == null ? null : gapToLeaderInOwnTime.asSeconds();
if (result.gapToLeaderInSeconds != null) { if (result.gapToLeaderInSeconds != null) {
Duration gapAtEndOfPreviousLeg = getGapAtEndOfPreviousLeg(trackedLeg, cache); final Duration gapAtEndOfPreviousLeg = getGapAtEndOfPreviousLeg(trackedLeg, cache);
if (gapAtEndOfPreviousLeg != null) { if (gapAtEndOfPreviousLeg != null) {
result.gapChangeSinceLegStartInSeconds = result.gapToLeaderInSeconds - gapAtEndOfPreviousLeg.asSeconds(); result.gapChangeSinceLegStartInSeconds = result.gapToLeaderInSeconds - gapAtEndOfPreviousLeg.asSeconds();
} }
@@ -1759,14 +1759,18 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
private Duration getGapAtEndOfPreviousLeg(TrackedLegOfCompetitor trackedLeg, WindLegTypeAndLegBearingCache cache) { private Duration getGapAtEndOfPreviousLeg(TrackedLegOfCompetitor trackedLeg, WindLegTypeAndLegBearingCache cache) {
final Duration result; final Duration result;
final Course course = trackedLeg.getTrackedLeg().getTrackedRace().getRace().getCourse(); final Course course = trackedLeg.getTrackedLeg().getTrackedRace().getRace().getCourse();
course.lockForRead(); // if trackedLeg is the first leg, compute the gap at the start of this leg; otherwise, compute gap
try { // at the end of the previous leg
result = trackedLeg.getTrackedLeg().getTrackedRace().getRankingMetric().getLegGapToLegLeaderInOwnTime( final TimePoint timePoint = trackedLeg.getStartTime();
trackedLeg, trackedLeg.getStartTime(), cache); final TrackedLegOfCompetitor tloc;
return result; if (course.getFirstWaypoint() == trackedLeg.getLeg().getFrom()) {
} finally { tloc = trackedLeg;
course.unlockAfterRead(); } else {
tloc = trackedLeg.getTrackedLeg().getTrackedRace().getTrackedLegFinishingAt(trackedLeg.getLeg().getFrom())
.getTrackedLeg(trackedLeg.getCompetitor());
} }
result = trackedLeg.getTrackedLeg().getTrackedRace().getRankingMetric().getLegGapToLegLeaderInOwnTime(tloc, timePoint, cache);
return result;
} }
private LeaderboardDTO getLiveLeaderboard(Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, private LeaderboardDTO getLiveLeaderboard(Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails,