mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
Live Now and Finished Races tables in Home.html are now mutually exclusive
This commit is contained in:
1 parent
aeb9e33130
commit
79949d98b8
3 files changed
+19
-15
No files matched your search
+11
-4
@@ -12,6 +12,13 @@ public class RaceTimesCalculationUtil {
|
||||
|
||||
public static Util.Pair<Date, Date> calculateRaceMinMax(Date liveTimePoint, Date startOfTracking, Date startOfRace,
|
||||
Date raceFinishingTime, Date raceFinishedTime, Date endOfRace, Date endOfTracking) {
|
||||
return calculateRaceMinMax(liveTimePoint, startOfTracking, startOfRace, raceFinishingTime, raceFinishedTime,
|
||||
endOfRace, endOfTracking, MIN_TIME_BEFORE_RACE_START, MAX_TIME_AFTER_RACE_END, TIME_AFTER_LIVE);
|
||||
}
|
||||
|
||||
public static Util.Pair<Date, Date> calculateRaceMinMax(Date liveTimePoint, Date startOfTracking, Date startOfRace,
|
||||
Date raceFinishingTime, Date raceFinishedTime, Date endOfRace, Date endOfTracking, long millisBeforeStart,
|
||||
long millisAfterEnd, long millisAfterLive) {
|
||||
if (liveTimePoint == null) {
|
||||
return new Util.Pair<Date, Date>(null, null);
|
||||
}
|
||||
@@ -21,7 +28,7 @@ public class RaceTimesCalculationUtil {
|
||||
// Range start / min
|
||||
if (startOfRace != null) {
|
||||
// We have a start time
|
||||
min = new Date(startOfRace.getTime() - MIN_TIME_BEFORE_RACE_START);
|
||||
min = new Date(startOfRace.getTime() - millisBeforeStart);
|
||||
} else if (startOfTracking != null) {
|
||||
// We at least have a start of tracking time
|
||||
min = startOfTracking;
|
||||
@@ -34,17 +41,17 @@ public class RaceTimesCalculationUtil {
|
||||
// Range end / max
|
||||
if (raceFinishedTime != null) {
|
||||
// We have a blue flag down event
|
||||
max = new Date(raceFinishedTime.getTime() + MAX_TIME_AFTER_RACE_END);
|
||||
max = new Date(raceFinishedTime.getTime() + millisAfterEnd);
|
||||
} else if (endOfRace != null && raceFinishingTime == null) {
|
||||
// We have NO blue flag up event and we have an end of race time
|
||||
max = new Date(endOfRace.getTime() + MAX_TIME_AFTER_RACE_END);
|
||||
max = new Date(endOfRace.getTime() + millisAfterEnd);
|
||||
} else {
|
||||
// We have no end time and are not expecting any end events
|
||||
if (endOfTracking != null && raceFinishingTime == null) {
|
||||
max = endOfTracking;
|
||||
} else {
|
||||
// No end in sight; Keep on playing
|
||||
max = new Date(liveTimePoint.getTime() + TIME_AFTER_LIVE);
|
||||
max = new Date(liveTimePoint.getTime() + millisAfterLive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -1204,18 +1204,14 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
finishingTime != null ? finishingTime.asDate() : null,
|
||||
finishedTime != null ? finishedTime.asDate() : null,
|
||||
endTime != null ? endTime.asDate() : null,
|
||||
endOfTracking != null ? endOfTracking.asDate() : null);
|
||||
Date min = minMax.getA() != null
|
||||
? new Date(minMax.getA().getTime() - TimingConstants.PRE_START_PHASE_DURATION_IN_MILLIS)
|
||||
: null;
|
||||
Date max = minMax.getB() != null
|
||||
? new Date(minMax.getB().getTime() + TimingConstants.IS_LIVE_GRACE_PERIOD_IN_MILLIS
|
||||
+ getDelayToLiveInMillis())
|
||||
: null;
|
||||
endOfTracking != null ? endOfTracking.asDate() : null,
|
||||
TimingConstants.PRE_START_PHASE_DURATION_IN_MILLIS,
|
||||
RaceTimesCalculationUtil.MAX_TIME_AFTER_RACE_END,
|
||||
TimingConstants.IS_LIVE_GRACE_PERIOD_IN_MILLIS);
|
||||
|
||||
// We are live if at is in between min and max
|
||||
if (min != null && max != null) {
|
||||
return !min.after(at.asDate()) && !at.asDate().after(max);
|
||||
if (minMax.getA() != null && minMax.getB() != null) {
|
||||
return !minMax.getA().after(at.asDate()) && !at.asDate().after(minMax.getB());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -340,7 +340,8 @@ public class RaceContext {
|
||||
public RaceListRaceDTO getFinishedRaceOrNull() {
|
||||
// a race is of 'public interest' of a race is a combination of it's 'live' state
|
||||
// and special flags states indicating how the postponed/canceled races will be continued
|
||||
if (getLiveRaceViewState() == RaceViewState.FINISHED) {
|
||||
// See: https://bugzilla.sapsailing.com/bugzilla/show_bug.cgi?id=5029
|
||||
if (getLiveRaceViewState() == RaceViewState.FINISHED && !isLiveOrOfPublicInterest()) {
|
||||
// the start time is always given for live races
|
||||
RaceListRaceDTO raceListRaceDTO = new RaceListRaceDTO(getLeaderboardName(),
|
||||
getRaceIdentifierOrNull(), getRaceName());
|
||||
|
||||
Reference in new issue
Block a user