Skip to content

Commit b323922

Browse files
committed
bug5959 aftermath: don't count same RaceColumn multiple times when looking for attached TrackedRace;
Delegating leaderboards were adding to the count, although they refer to the same RaceColumn to which the same TrackedRace is attached. Therefore, waiting for the number of attached RaceLogs would wait endlessly because only one race log got attached for the single RaceColumn.
1 parent ba2ea52 commit b323922

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,10 @@ protected void load(Consumer<Double> progressConsumer, BooleanSupplier stopCallb
964964
}
965965

966966
/**
967-
* This is used when device mappings for an item changed so that fixes in a new {@link TimeRange} are covered. This is also used when initially loading fixes due to startOfTracking being initially set. If
968-
* the mapping is a {@link Mark}, best fixes outside of the tracking {@link TimeRange} are loaded if none is
969-
* available in the tracking {@link TimeRange}.
967+
* This is used when device mappings for an item changed so that fixes in a new {@link TimeRange} are covered. This
968+
* is also used when initially loading fixes due to startOfTracking being initially set. If the mapping is a
969+
* {@link Mark}, best fixes outside of the tracking {@link TimeRange} are loaded if none is available in the
970+
* tracking {@link TimeRange}.
970971
*/
971972
private class LoadFixesForNewlyCoveredTimeRangesJob extends AbstractLoadingJob {
972973
private final WithID item;

java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/RaceLogAndTrackedRaceResolver.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.sap.sailing.domain.base.RaceColumn;
1010
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
1111
import com.sap.sailing.domain.leaderboard.Leaderboard;
12+
import com.sap.sailing.domain.leaderboard.impl.DelegatingRegattaLeaderboardWithCompetitorElimination;
1213
import com.sap.sailing.domain.regattalike.IsRegattaLike;
1314
import com.sap.sailing.domain.tracking.TrackedRace;
1415
import com.sap.sse.common.Util.Triple;
@@ -31,13 +32,20 @@ public interface RaceLogAndTrackedRaceResolver extends RaceLogResolver {
3132
/**
3233
* Determines those {@link RaceColumn}/{@link Fleet} combinations ("slots") from all {@link Leaderboard}s managed by
3334
* this resolver that the tracked race identified by {@code trackedRaceIdentifier} shall be linked to when loaded.
34-
* This information is relevant, e.g., after having created a {@link TrackedRace} that previously was attached to
35-
* one or more such "slots" and shall now be re-connected to those same slots again. It is also helpful, e.g., when
36-
* trying to figure out which race logs will be
35+
* Duplicate {@link RaceColumn}s are ignored; such duplicates may occur, e.g., if one {@link Leaderboard} is a view
36+
* of another one, as is the case for a {@link DelegatingRegattaLeaderboardWithCompetitorElimination}. In such
37+
* scenarios, the leaderboard returned as the {@link Triple#getA() first} component of the resulting triple is
38+
* randomly picked from those leaderboards {@link Leaderboard#getRaceColumns() listing} this column.
39+
* <p>
40+
*
41+
* The information returned is relevant, e.g., after having created a {@link TrackedRace} that previously was
42+
* attached to one or more such "slots" and shall now be re-connected to those same slots again. It is also helpful,
43+
* e.g., when trying to figure out which race logs will be
3744
* {@link TrackedRace#attachRegattaLog(com.sap.sailing.domain.abstractlog.regatta.RegattaLog) attached} to that
3845
* {@link TrackedRace} because usually each "slot" comes with its own {@link RaceLog}, so that attaching to multiple
3946
* slots will result in multiple race logs being attached to the tracked race.
4047
*/
41-
List<Triple<Leaderboard, RaceColumn, Fleet>> getColumnsWithRaceLogForTrackedRace(RegattaAndRaceIdentifier trackedRaceIdentifier);
48+
List<Triple<Leaderboard, RaceColumn, Fleet>> getColumnsWithRaceLogForTrackedRace(
49+
RegattaAndRaceIdentifier trackedRaceIdentifier);
4250

4351
}

java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,12 +2743,15 @@ private List<Triple<Leaderboard, RaceColumn, Fleet>> linkRaceToConfiguredLeaderb
27432743
@Override
27442744
public List<Triple<Leaderboard, RaceColumn, Fleet>> getColumnsWithRaceLogForTrackedRace(
27452745
final RegattaAndRaceIdentifier trackedRaceIdentifier) {
2746+
final Set<RaceColumn> raceColumnsVisited = new HashSet<>();
27462747
final List<Triple<Leaderboard, RaceColumn, Fleet>> trackedRaceLink = new ArrayList<>();
27472748
for (Leaderboard leaderboard : getLeaderboards().values()) {
27482749
for (RaceColumn column : leaderboard.getRaceColumns()) {
2749-
for (Fleet fleet : column.getFleets()) {
2750-
if (trackedRaceIdentifier.equals(column.getRaceIdentifier(fleet))) {
2751-
trackedRaceLink.add(new Triple<>(leaderboard, column, fleet));
2750+
if (raceColumnsVisited.add(column)) { // avoid visiting the same column multiple times in case it's shared across multiple leaderboards
2751+
for (Fleet fleet : column.getFleets()) {
2752+
if (trackedRaceIdentifier.equals(column.getRaceIdentifier(fleet))) {
2753+
trackedRaceLink.add(new Triple<>(leaderboard, column, fleet));
2754+
}
27522755
}
27532756
}
27542757
}

0 commit comments

Comments
 (0)