mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 11:40:01 +00:00
consistently changed remaining Integer occurrences to Double in EditableLeaderboard; fixed score correction metadata persistence and added test
This commit is contained in:
1 parent
3616e09138
commit
6efb6be4ea
12 files changed
+51
-14
No files matched your search
+12
-2
@@ -199,7 +199,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
if (result != null) {
|
||||
DelayedLeaderboardCorrections loadedLeaderboardCorrections = new DelayedLeaderboardCorrectionsImpl(result);
|
||||
loadLeaderboardCorrections(dbLeaderboard, loadedLeaderboardCorrections);
|
||||
loadLeaderboardCorrections(dbLeaderboard, loadedLeaderboardCorrections, scoreCorrection);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -262,7 +262,8 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void loadLeaderboardCorrections(DBObject dbLeaderboard, DelayedLeaderboardCorrections correctionsToUpdate) {
|
||||
private void loadLeaderboardCorrections(DBObject dbLeaderboard, DelayedLeaderboardCorrections correctionsToUpdate,
|
||||
SettableScoreCorrection scoreCorrectionToUpdate) {
|
||||
DBObject carriedPoints = (DBObject) dbLeaderboard.get(FieldNames.LEADERBOARD_CARRIED_POINTS.name());
|
||||
if (carriedPoints != null) {
|
||||
for (String competitorName : carriedPoints.keySet()) {
|
||||
@@ -273,6 +274,15 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
}
|
||||
DBObject dbScoreCorrection = (DBObject) dbLeaderboard.get(FieldNames.LEADERBOARD_SCORE_CORRECTIONS.name());
|
||||
if (dbScoreCorrection.containsField(FieldNames.LEADERBOARD_SCORE_CORRECTION_TIMESTAMP.name())) {
|
||||
scoreCorrectionToUpdate.setTimePointOfLastCorrectionsValidity(
|
||||
new MillisecondsTimePoint((Long) dbScoreCorrection.get(FieldNames.LEADERBOARD_SCORE_CORRECTION_TIMESTAMP.name())));
|
||||
dbScoreCorrection.removeField(FieldNames.LEADERBOARD_SCORE_CORRECTION_TIMESTAMP.name());
|
||||
}
|
||||
if (dbScoreCorrection.containsField(FieldNames.LEADERBOARD_SCORE_CORRECTION_COMMENT.name())) {
|
||||
scoreCorrectionToUpdate.setComment((String) dbScoreCorrection.get(FieldNames.LEADERBOARD_SCORE_CORRECTION_COMMENT.name()));
|
||||
dbScoreCorrection.removeField(FieldNames.LEADERBOARD_SCORE_CORRECTION_COMMENT.name());
|
||||
}
|
||||
for (String raceName : dbScoreCorrection.keySet()) {
|
||||
DBObject dbScoreCorrectionForRace = (DBObject) dbScoreCorrection.get(raceName);
|
||||
for (String competitorName : dbScoreCorrectionForRace.keySet()) {
|
||||
|
||||
+3
-2
@@ -41,11 +41,12 @@ public enum FieldNames {
|
||||
|
||||
// leaderboard:
|
||||
LEADERBOARD_NAME, LEADERBOARD_COLUMNS, LEADERBOARD_COLUMN_NAME, LEADERBOARD_COMPETITOR_DISPLAY_NAMES, LEADERBOARD_IS_MEDAL_RACE_COLUMN,
|
||||
LEADERBOARD_CARRIED_POINTS, LEADERBOARD_SCORE_CORRECTIONS, LEADERBOARD_DISCARDING_THRESHOLDS, LEADERBOARD_SCORE_CORRECTION_MAX_POINTS_REASON, LEADERBOARD_CORRECTED_SCORE,
|
||||
LEADERBOARD_CARRIED_POINTS, LEADERBOARD_SCORE_CORRECTIONS, LEADERBOARD_DISCARDING_THRESHOLDS, LEADERBOARD_SCORE_CORRECTION_MAX_POINTS_REASON,
|
||||
LEADERBOARD_CORRECTED_SCORE, LEADERBOARD_SCORE_CORRECTION_TIMESTAMP, LEADERBOARD_SCORE_CORRECTION_COMMENT,
|
||||
|
||||
// leaderboard group
|
||||
LEADERBOARD_GROUP_NAME, LEADERBOARD_GROUP_DESCRIPTION, LEADERBOARD_GROUP_LEADERBOARDS,
|
||||
|
||||
// race ID to regatta name
|
||||
RACE_ID_AS_STRING
|
||||
RACE_ID_AS_STRING;
|
||||
}
|
||||
+8
@@ -25,6 +25,7 @@ import com.sap.sailing.domain.common.Bearing;
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
@@ -218,6 +219,13 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
dbScoreCorrections.put(raceColumn.getName(), dbCorrectionForRace);
|
||||
}
|
||||
}
|
||||
final TimePoint timePointOfLastCorrectionsValidity = scoreCorrection.getTimePointOfLastCorrectionsValidity();
|
||||
if (timePointOfLastCorrectionsValidity != null) {
|
||||
dbScoreCorrections.put(FieldNames.LEADERBOARD_SCORE_CORRECTION_TIMESTAMP.name(), timePointOfLastCorrectionsValidity.asMillis());
|
||||
}
|
||||
if (scoreCorrection.getComment() != null) {
|
||||
dbScoreCorrections.put(FieldNames.LEADERBOARD_SCORE_CORRECTION_COMMENT.name(), scoreCorrection.getComment());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public interface SettableScoreCorrection extends ScoreCorrection {
|
||||
|
||||
boolean hasCorrectionFor(RaceColumn raceInLeaderboard);
|
||||
|
||||
void setLastCorrected(TimePoint timePointOfLastCorrectionsValidity);
|
||||
void setTimePointOfLastCorrectionsValidity(TimePoint timePointOfLastCorrectionsValidity);
|
||||
|
||||
void setComment(String scoreCorrectionComment);
|
||||
}
|
||||
+1
-1
@@ -185,7 +185,7 @@ public class ScoreCorrectionImpl implements SettableScoreCorrection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastCorrected(TimePoint timePointOfLastCorrectionsValidity) {
|
||||
public void setTimePointOfLastCorrectionsValidity(TimePoint timePointOfLastCorrectionsValidity) {
|
||||
this.timePointOfLastCorrectionsValidity = timePointOfLastCorrectionsValidity;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
Map<String, RegattaAndRaceIdentifier> getRegattaAndRaceNameOfTrackedRaceConnectedToLeaderboardColumn(String leaderboardName, String raceColumnName);
|
||||
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Integer carriedPoints);
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Double carriedPoints);
|
||||
|
||||
/**
|
||||
* @return the new net points in {@link Pair#getA()} and the new total points in {@link Pair#getB()} for time point
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ public interface SailingServiceAsync {
|
||||
void disconnectLeaderboardColumnFromTrackedRace(String leaderboardName, String raceColumnName, String fleetName,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Integer carriedPoints, AsyncCallback<Void> callback);
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Double carriedPoints, AsyncCallback<Void> callback);
|
||||
|
||||
void updateLeaderboardMaxPointsReason(String leaderboardName, String competitorIdAsString, String raceColumnName,
|
||||
MaxPointsReason maxPointsReason, Date date, AsyncCallback<Triple<Double, Double, Boolean>> asyncCallback);
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
@Override
|
||||
public void update(final int rowIndex, final LeaderboardRowDTO row, final String value) {
|
||||
getSailingService().updateLeaderboardCarryValue(getLeaderboardName(), row.competitor.id,
|
||||
value == null || value.length() == 0 ? null : Integer.valueOf(value.trim()),
|
||||
value == null || value.length() == 0 ? null : Double.valueOf(value.trim()),
|
||||
new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
@@ -338,7 +338,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
getBusyIndicator().setBusy(false);
|
||||
final LeaderboardEntryDTO leaderboardEntryDTO = row.fieldsByRaceColumnName.get(raceName);
|
||||
leaderboardEntryDTO.netPoints = value == null || value.length() == 0 ? newNetAndTotalPointsAndIsCorrected
|
||||
.getA() : Integer.valueOf(value.trim());
|
||||
.getA() : Double.valueOf(value.trim());
|
||||
leaderboardEntryDTO.totalPoints = newNetAndTotalPointsAndIsCorrected.getB();
|
||||
leaderboardEntryDTO.netPointsCorrected = newNetAndTotalPointsAndIsCorrected.getC();
|
||||
getCell().setViewData(row, null); // ensure that getValue() is called again
|
||||
|
||||
+1
-1
@@ -1947,7 +1947,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Integer carriedPoints) {
|
||||
public void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Double carriedPoints) {
|
||||
getService().apply(new UpdateLeaderboardCarryValue(leaderboardName, competitorIdAsString, carriedPoints));
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -14,6 +14,7 @@ import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.impl.BoatClassImpl;
|
||||
import com.sap.sailing.domain.base.impl.BoatImpl;
|
||||
import com.sap.sailing.domain.base.impl.CompetitorImpl;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.base.impl.NationalityImpl;
|
||||
import com.sap.sailing.domain.base.impl.PersonImpl;
|
||||
import com.sap.sailing.domain.base.impl.TeamImpl;
|
||||
@@ -21,6 +22,7 @@ import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.SettableScoreCorrection;
|
||||
import com.sap.sailing.domain.leaderboard.impl.FlexibleLeaderboardImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.LowerScoreIsBetter;
|
||||
import com.sap.sailing.domain.leaderboard.impl.ResultDiscardingRuleImpl;
|
||||
@@ -31,6 +33,22 @@ import com.sap.sailing.domain.test.MockedTrackedRaceWithFixedRank;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
|
||||
public class TestStoringAndRetrievingLeaderboards extends AbstractMongoDBTest {
|
||||
@Test
|
||||
public void testStoreAndRetrieveLeaderboardWithCommentedScoreCorrection() {
|
||||
final String leaderboardName = "TestLeaderboard";
|
||||
final int[] discardIndexResultsStartingWithHowManyRaces = new int[] { 5, 8 };
|
||||
SettableScoreCorrection scoreCorrection = new ScoreCorrectionImpl();
|
||||
FlexibleLeaderboardImpl leaderboard = new FlexibleLeaderboardImpl(leaderboardName, scoreCorrection,
|
||||
new ResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces), new LowerScoreIsBetter());
|
||||
scoreCorrection.setComment("Humba");
|
||||
MillisecondsTimePoint now = MillisecondsTimePoint.now();
|
||||
scoreCorrection.setTimePointOfLastCorrectionsValidity(now);
|
||||
new MongoObjectFactoryImpl(db).storeLeaderboard(leaderboard);
|
||||
Leaderboard loadedLeaderboard = new DomainObjectFactoryImpl(db).loadLeaderboard(leaderboardName, /* regattaRegistry */ null);
|
||||
assertEquals("Humba", loadedLeaderboard.getScoreCorrection().getComment());
|
||||
assertEquals(now, loadedLeaderboard.getScoreCorrection().getTimePointOfLastCorrectionsValidity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboard() {
|
||||
final String leaderboardName = "TestLeaderboard";
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@ import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
public class UpdateLeaderboardCarryValue extends AbstractLeaderboardOperation<Void> {
|
||||
private static final long serialVersionUID = 5467731814788887426L;
|
||||
private final String competitorIdAsString;
|
||||
private final Integer newCarriedValue;
|
||||
private final Double newCarriedValue;
|
||||
|
||||
public UpdateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Integer newCarriedValue) {
|
||||
public UpdateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Double newCarriedValue) {
|
||||
super(leaderboardName);
|
||||
this.competitorIdAsString = competitorIdAsString;
|
||||
this.newCarriedValue = newCarriedValue;
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class UpdateLeaderboardScoreCorrectionMetadata extends AbstractLeaderboar
|
||||
SettableScoreCorrection scoreCorrection = leaderboard.getScoreCorrection();
|
||||
if (scoreCorrection != null) {
|
||||
scoreCorrection.setComment(comment);
|
||||
scoreCorrection.setLastCorrected(timePointOfLastCorrectionValidity);
|
||||
scoreCorrection.setTimePointOfLastCorrectionsValidity(timePointOfLastCorrectionValidity);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Leaderboard "+getLeaderboardName()+" has no score corrections to which to apply metadata "+
|
||||
timePointOfLastCorrectionValidity+"/"+comment);
|
||||
|
||||
Reference in new issue
Block a user