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