[Fix] Allow only specific types only in search results #2
@ -12,14 +12,18 @@ import com.backend.search.kodik.service.anyame_backend.api.model.KodikResponse.R
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class KodikSearchFilterService {
|
public class KodikSearchFilterService {
|
||||||
|
private static final List<String> ALLOWED_TYPES = Arrays.asList("anime-serial", "anime");
|
||||||
|
|
||||||
public KodikResponse filter(KodikResponse body) {
|
public KodikResponse filter(KodikResponse body) {
|
||||||
Set<String> seenIds = new HashSet<>();
|
Set<String> seenIds = new HashSet<>();
|
||||||
List<Result> filteredResults = body.results.stream().filter(result -> {
|
List<Result> filteredResults = body.results.stream()
|
||||||
|
.filter(result -> ALLOWED_TYPES.contains(result.type))
|
||||||
|
.filter(result -> {
|
||||||
String identifier = identifier(result);
|
String identifier = identifier(result);
|
||||||
boolean updated = seenIds.add(identifier);
|
boolean updated = seenIds.add(identifier);
|
||||||
return updated;
|
return updated;
|
||||||
}).toList();
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
body.results = filteredResults;
|
body.results = filteredResults;
|
||||||
return body;
|
return body;
|
||||||
|
Reference in New Issue
Block a user