fix: support fuzzy logs user search

This commit is contained in:
2026-05-08 20:20:24 +08:00
parent 63eec82931
commit b1539f3969
2 changed files with 63 additions and 6 deletions

View File

@@ -692,8 +692,14 @@ export async function getLogs(options: {
let where = timeWhere(params, options.startTs, options.endTs);
if (options.username) {
params.push(options.username);
where += ` AND username = $${params.length}`;
params.push(`%${options.username}%`);
where += ` AND (
username ILIKE $${params.length}
OR user_id IN (
SELECT id FROM users
WHERE display_name ILIKE $${params.length} OR users.username ILIKE $${params.length}
)
)`;
}
if (options.model) {
params.push(options.model);