fixing bug 3482: Time Slider extends until "now" for SwissTiming Olympics 2012 Replay Races;

the fix now considers the newest tracking event and/or endOfRace in case startOfTracking
and endOfTracking are both null
This commit is contained in:
Axel Uhl committed 2016-02-27 21:41:31 +01:00
1 parent ff22bb7313
commit c197ed177e
2 files changed
+36 -8

No files matched your search

@@ -142,18 +142,46 @@ public class RaceTimePanel extends TimePanel<RaceTimePanelSettings> implements R
/**
* If and only if the {@link #selectedRace}'s timing is described by the {@link #raceTimesInfoProvider} and
* according to the timing the current live time point is after the start of tracking or at least after three
* minutes before the race, and the current live time point is not after the end of tracking then live mode will be
* made possible (<code>true</code> will be returned).
* according to the timing the current live time point is after the start of tracking or at least after
* {@link RaceTimesCalculationUtil.MIN_TIME_BEFORE_RACE_START} minutes before the race, and the current live time
* point is not after the end of tracking then live mode will be made possible (<code>true</code> will be returned).<p>
*
* Bug 3482: when startOfTracking and endOfTracking are both {@code null} it would be good to check for the
* {@link RaceTimesInfoDTO#newestTrackingEvent} and {@link RaceTimesInfoDTO#endOfRace} values to see if---with
* a little leeway---an end for the live period may be determined. Without this logic, such races would remain
* live until the end of time.
*/
@Override
protected boolean isLiveModeToBeMadePossible() {
long liveTimePointInMillis = timer.getLiveTimePointInMillis();
RaceTimesInfoDTO lastRaceTimesInfo = raceTimesInfoProvider != null ? raceTimesInfoProvider.getRaceTimesInfo(selectedRace) : null;
return lastRaceTimesInfo != null &&
final boolean isLiveModeToBeMadePossible;
if (lastRaceTimesInfo != null &&
// check that we're after startOfTracking or startOfRace minus some leeway:
((lastRaceTimesInfo.startOfTracking != null && liveTimePointInMillis > lastRaceTimesInfo.startOfTracking.getTime()) ||
(lastRaceTimesInfo.startOfRace != null && liveTimePointInMillis > lastRaceTimesInfo.startOfRace.getTime() - RaceTimesCalculationUtil.MIN_TIME_BEFORE_RACE_START)) &&
(lastRaceTimesInfo.endOfTracking == null || liveTimePointInMillis <= lastRaceTimesInfo.endOfTracking.getTime());
(lastRaceTimesInfo.startOfRace != null && liveTimePointInMillis > lastRaceTimesInfo.startOfRace.getTime() - RaceTimesCalculationUtil.MIN_TIME_BEFORE_RACE_START))) {
// now check that we cannot know about an end time or are reasonably before it;
// we don't know about the end time if startOfTracking is valid but endOfTracking is not;
// neither do we know about the end time if both, startOfTracking and endOfTracking are null
// and we have neither a valid newestTrackingEvent nor an endOfRace value; if we do, we would
// have to be before the later one plus some leeway.
final Date endTimeOfLivePeriod;
if (lastRaceTimesInfo.startOfTracking == null && lastRaceTimesInfo.endOfTracking == null) {
Date latestOfNewestTrackingEventAndEndOfRace = lastRaceTimesInfo.newestTrackingEvent;
if (latestOfNewestTrackingEventAndEndOfRace == null || (lastRaceTimesInfo.endOfRace != null && lastRaceTimesInfo.endOfRace.after(latestOfNewestTrackingEventAndEndOfRace))) {
latestOfNewestTrackingEventAndEndOfRace = lastRaceTimesInfo.endOfRace;
}
endTimeOfLivePeriod = latestOfNewestTrackingEventAndEndOfRace == null ? null :
new Date(latestOfNewestTrackingEventAndEndOfRace.getTime() + RaceTimesCalculationUtil.TIME_AFTER_LIVE);
} else {
endTimeOfLivePeriod = lastRaceTimesInfo.endOfTracking == null ? null : lastRaceTimesInfo.endOfTracking;
}
isLiveModeToBeMadePossible = endTimeOfLivePeriod == null /* meaning we don't know an end time */ ||
endTimeOfLivePeriod.getTime() >= liveTimePointInMillis;
} else {
isLiveModeToBeMadePossible = false;
}
return isLiveModeToBeMadePossible;
}
@Override
@@ -8,8 +8,8 @@ import com.sap.sse.gwt.client.player.Timer;
public class RaceTimesCalculationUtil {
public static final long MIN_TIME_BEFORE_RACE_START = 3 * 60 * 1000; // 3 minutes
private static final long MIN_TIME_AFTER_RACE_START = 5 * 60 * 1000; // 5 minutes
private static final long TIME_AFTER_LIVE = 5 * 60 * 1000; // 5 minutes
public static final long MIN_TIME_AFTER_RACE_START = 5 * 60 * 1000; // 5 minutes
public static final long TIME_AFTER_LIVE = 5 * 60 * 1000; // 5 minutes
public static final long MAX_TIME_AFTER_RACE_END = 1 * 60 * 1000; // 1 minutes
public static Util.Pair<Date, Date> caluclateRaceMinMax(Timer timer, RaceTimesInfoDTO raceTimesInfo) {