mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 19:33:52 +00:00
can compute the races won and use them to rank in case of a tie
This commit is contained in:
1 parent
7b803bf58b
commit
62c29675fa
2 files changed
+24
-2
No files matched your search
+2
-1
@@ -182,9 +182,10 @@ public class WindPanel extends FormPanel implements EventDisplayer, RaceSelectio
|
||||
|
||||
@Override
|
||||
public void showWind(final EventDAO event, final RaceDAO race) {
|
||||
Date now = new Date();
|
||||
sailingService.getWindInfo(event.name, race.name,
|
||||
// TODO what about the time interval?
|
||||
new Date(/* fromAsMilliseconds */0), new Date(/* toAsMilliseconds */),
|
||||
new Date(now.getTime()-60000 /* one minute */), new Date(/* toAsMilliseconds */),
|
||||
showEstimatedWindBox.getValue(), new AsyncCallback<WindInfoForRaceDAO>() {
|
||||
@Override
|
||||
public void onSuccess(WindInfoForRaceDAO result) {
|
||||
|
||||
+22
-1
@@ -96,7 +96,14 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
// neither one scored in any medal race
|
||||
result = getTotalPoints(o1) - getTotalPoints(o2);
|
||||
}
|
||||
|
||||
}
|
||||
// Now if both have equal points, count races won.
|
||||
if (result == 0) {
|
||||
result = getNumberOfRacesWon(o2.competitor) - getNumberOfRacesWon(o1.competitor);
|
||||
}
|
||||
// If number of races won is still equal, use rank in last race
|
||||
if (result == 0) {
|
||||
// TODO how to find "last" race?
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -143,6 +150,20 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
competitorsOrderedAccordingToTotalRank = false;
|
||||
}
|
||||
|
||||
private int getNumberOfRacesWon(CompetitorDAO competitor) {
|
||||
int result = 0;
|
||||
LeaderboardRowDAO row = rows.get(competitor);
|
||||
if (row != null) {
|
||||
for (String raceName : raceNamesAndMedalRaceAndTracked.keySet()) {
|
||||
LeaderboardEntryDAO field = row.fieldsByRaceName.get(raceName);
|
||||
if (field != null && field.netPoints == 1) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getRank(CompetitorDAO competitor) {
|
||||
if (!competitorsOrderedAccordingToTotalRank) {
|
||||
Collections.sort(competitors, new Comparator<CompetitorDAO>() {
|
||||
|
||||
Reference in new issue
Block a user