feat(logs): widen source filter to multi-value OR list
Replaces LogSearchRequest.source (String) with sources (List<String>) and emits 'source IN (...)' when non-empty. LogQueryController parses ?source=a,b,c the same way it parses ?level=a,b,c.
This commit is contained in:
@@ -61,12 +61,20 @@ public class LogQueryController {
|
||||
.toList();
|
||||
}
|
||||
|
||||
List<String> sources = List.of();
|
||||
if (source != null && !source.isEmpty()) {
|
||||
sources = Arrays.stream(source.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.toList();
|
||||
}
|
||||
|
||||
Instant fromInstant = from != null ? Instant.parse(from) : null;
|
||||
Instant toInstant = to != null ? Instant.parse(to) : null;
|
||||
|
||||
LogSearchRequest request = new LogSearchRequest(
|
||||
searchText, levels, application, instanceId, exchangeId,
|
||||
logger, env.slug(), source, fromInstant, toInstant, cursor, limit, sort);
|
||||
logger, env.slug(), sources, fromInstant, toInstant, cursor, limit, sort);
|
||||
|
||||
LogSearchResponse result = logIndex.search(request);
|
||||
|
||||
|
||||
@@ -146,9 +146,12 @@ public class ClickHouseLogStore implements LogIndex {
|
||||
baseParams.add("%" + escapeLike(request.logger()) + "%");
|
||||
}
|
||||
|
||||
if (request.source() != null && !request.source().isEmpty()) {
|
||||
baseConditions.add("source = ?");
|
||||
baseParams.add(request.source());
|
||||
if (request.sources() != null && !request.sources().isEmpty()) {
|
||||
String placeholders = String.join(", ", Collections.nCopies(request.sources().size(), "?"));
|
||||
baseConditions.add("source IN (" + placeholders + ")");
|
||||
for (String s : request.sources()) {
|
||||
baseParams.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (request.from() != null) {
|
||||
|
||||
Reference in New Issue
Block a user