mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
Merge branch 'master' into bug2822_boatcolors
This commit is contained in:
+42
-3
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.server.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -79,7 +80,7 @@ public class RegattaByKeywordSearchService {
|
||||
if (leaderboardGroupsHostingLeaderboard != null) {
|
||||
for (LeaderboardGroup leaderboardGroup : leaderboardGroupsHostingLeaderboard) {
|
||||
leaderboardStrings.addAll(stringsForLeaderboardGroup.get(leaderboardGroup));
|
||||
final Set<Event> eventsForLG = eventsForLeaderboardGroup.get(leaderboardGroup);
|
||||
final Set<Event> eventsForLG = filterEventsForLeaderboard(leaderboard, leaderboardGroup, eventsForLeaderboardGroup.get(leaderboardGroup));
|
||||
if (eventsForLG != null) {
|
||||
for (final Event event : eventsForLG) {
|
||||
leaderboardStrings.addAll(stringsForEvent.get(event));
|
||||
@@ -91,7 +92,6 @@ public class RegattaByKeywordSearchService {
|
||||
if (eventByDefaultCourseArea != null) {
|
||||
leaderboardStrings.addAll(stringsForEvent.get(eventByDefaultCourseArea));
|
||||
}
|
||||
// FIXME bug 3348: for event series the "containment" between event and leaderboard group works the other way: one leaderboard group hosts the leaderboards of a series of events
|
||||
return leaderboardStrings;
|
||||
}
|
||||
};
|
||||
@@ -103,6 +103,45 @@ public class RegattaByKeywordSearchService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* For leaderboards that are part of a series, there used to be search results that linked to the leaderboard in
|
||||
* combination with one random event of that series. It was the wrong event for all leaderboards except one of a
|
||||
* series. In bug3348 a change was made to show all events associated to a leaderboard in the search results. This
|
||||
* lead to an "explosion of results" as there were potentially n results referencing n events instead of each result
|
||||
* only referencing the associated event.
|
||||
*
|
||||
* This filters the events to be associated to a leaderboard. If the leaderboardGroup has a OverallLeaderboard (in
|
||||
* case of a series), there is a special matching to find the right event. If a leaderboard has a defaultCourseArea,
|
||||
* the event hosting this CourseArea is the right one. If this reference isn't given or the CourseArea doesn't
|
||||
* belong to an event of the series, the fallback behavior is causing all events to be returned.
|
||||
*
|
||||
* This doesn't affect any leaderboard's event set if the leaderboard isn't part of a series.
|
||||
*
|
||||
* @param leaderboard the leaderboard to get the matching events for
|
||||
* @param leaderboardGroup the LeaderboardGroup hosting the leaderboard
|
||||
* @param events all events hosting the LeaderboardGroup
|
||||
* @return the best matching events for the given Leaderboard/LeaderboardGroup
|
||||
*/
|
||||
private Set<Event> filterEventsForLeaderboard(Leaderboard leaderboard, LeaderboardGroup leaderboardGroup, Set<Event> events) {
|
||||
final Set<Event> result;
|
||||
if (leaderboardGroup.hasOverallLeaderboard()) {
|
||||
CourseArea defaultCourseArea = leaderboard.getDefaultCourseArea();
|
||||
Set<Event> preResult = null;
|
||||
if (defaultCourseArea != null) {
|
||||
for (Event event : events) {
|
||||
if (Util.contains(event.getVenue().getCourseAreas(), defaultCourseArea)) {
|
||||
preResult = Collections.singleton(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = preResult;
|
||||
} else {
|
||||
result = events;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Set<Event> getEventsForLeaderboard(Leaderboard matchingLeaderboard,
|
||||
Map<Leaderboard, Set<LeaderboardGroup>> leaderboardGroupsForLeaderboard,
|
||||
@@ -111,7 +150,7 @@ public class RegattaByKeywordSearchService {
|
||||
final Set<LeaderboardGroup> lgs = leaderboardGroupsForLeaderboard.get(matchingLeaderboard);
|
||||
if (lgs != null) {
|
||||
for (final LeaderboardGroup lg : lgs) {
|
||||
final Set<Event> eventsForLG = eventsForLeaderboardGroup.get(lg);
|
||||
final Set<Event> eventsForLG = filterEventsForLeaderboard(matchingLeaderboard, lg, eventsForLeaderboardGroup.get(lg));
|
||||
if (eventsForLG != null) {
|
||||
result.addAll(eventsForLG);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user