mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Changed how first filter with CompleteSetException works
Now if the first filter instead says (skip) and returns 0 players. I considered that all players could be returned, but it is better if users get to choose their filter again in this case. Affects issues: - Fixed #1742
This commit is contained in:
parent
2ab789f3d8
commit
66eb192735
@ -39,12 +39,15 @@ public interface Filter {
|
||||
* @param query Query for the filter
|
||||
* @return Set of UUIDs this filter applies to
|
||||
* @throws IllegalArgumentException If the arguments are not valid.
|
||||
* @throws CompleteSetException If the arguments produce a complete set.
|
||||
*/
|
||||
Set<UUID> getMatchingUUIDs(SpecifiedFilterInformation query);
|
||||
|
||||
default Result apply(SpecifiedFilterInformation query) {
|
||||
try {
|
||||
return new Result(null, getKind(), getMatchingUUIDs(query));
|
||||
} catch (CompleteSetException allMatch) {
|
||||
return new Result(null, getKind() + " (skip)", new HashSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
class Result {
|
||||
@ -62,9 +65,13 @@ public interface Filter {
|
||||
}
|
||||
|
||||
public Result apply(Filter filter, SpecifiedFilterInformation query) {
|
||||
try {
|
||||
Set<UUID> got = filter.getMatchingUUIDs(query);
|
||||
currentUUIDs.retainAll(got);
|
||||
return new Result(this, filter.getKind(), currentUUIDs);
|
||||
} catch (CompleteSetException allMatch) {
|
||||
return notApplied(filter);
|
||||
}
|
||||
}
|
||||
|
||||
public Result notApplied(Filter filter) {
|
||||
|
@ -96,8 +96,7 @@ public class QueryFilters {
|
||||
String kind = specifiedFilterInformation.getKind();
|
||||
Filter filter = getFilter(kind).orElseThrow(() -> new BadRequestException("Filter kind not supported: '" + kind + "'"));
|
||||
|
||||
current = getResult(current, filter, specifiedFilterInformation);
|
||||
return current;
|
||||
return getResult(current, filter, specifiedFilterInformation);
|
||||
}
|
||||
|
||||
private Filter.Result getResult(Filter.Result current, Filter filter, SpecifiedFilterInformation query) {
|
||||
@ -107,8 +106,6 @@ public class QueryFilters {
|
||||
throw new BadRequestException("Bad parameters for filter '" + filter.getKind() +
|
||||
"': expecting " + Arrays.asList(filter.getExpectedParameters()) +
|
||||
", but was given " + query.getSetParameters());
|
||||
} catch (CompleteSetException complete) {
|
||||
return current == null ? null : current.notApplied(filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user