mirror of
https://github.com/openai/codex.git
synced 2026-05-04 13:21:54 +03:00
feat: improve logs client (#10229)
This commit is contained in:
@@ -457,28 +457,54 @@ fn push_log_filters<'a>(builder: &mut QueryBuilder<'a, Sqlite>, query: &'a LogQu
|
||||
if let Some(to_ts) = query.to_ts {
|
||||
builder.push(" AND ts <= ").push_bind(to_ts);
|
||||
}
|
||||
if let Some(module_like) = query.module_like.as_ref() {
|
||||
builder
|
||||
.push(" AND module_path LIKE '%' || ")
|
||||
.push_bind(module_like.as_str())
|
||||
.push(" || '%'");
|
||||
}
|
||||
if let Some(file_like) = query.file_like.as_ref() {
|
||||
builder
|
||||
.push(" AND file LIKE '%' || ")
|
||||
.push_bind(file_like.as_str())
|
||||
.push(" || '%'");
|
||||
}
|
||||
if let Some(thread_id) = query.thread_id.as_ref() {
|
||||
builder
|
||||
.push(" AND thread_id = ")
|
||||
.push_bind(thread_id.as_str());
|
||||
push_like_filters(builder, "module_path", &query.module_like);
|
||||
push_like_filters(builder, "file", &query.file_like);
|
||||
let has_thread_filter = !query.thread_ids.is_empty() || query.include_threadless;
|
||||
if has_thread_filter {
|
||||
builder.push(" AND (");
|
||||
let mut needs_or = false;
|
||||
for thread_id in &query.thread_ids {
|
||||
if needs_or {
|
||||
builder.push(" OR ");
|
||||
}
|
||||
builder.push("thread_id = ").push_bind(thread_id.as_str());
|
||||
needs_or = true;
|
||||
}
|
||||
if query.include_threadless {
|
||||
if needs_or {
|
||||
builder.push(" OR ");
|
||||
}
|
||||
builder.push("thread_id IS NULL");
|
||||
}
|
||||
builder.push(")");
|
||||
}
|
||||
if let Some(after_id) = query.after_id {
|
||||
builder.push(" AND id > ").push_bind(after_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn push_like_filters<'a>(
|
||||
builder: &mut QueryBuilder<'a, Sqlite>,
|
||||
column: &str,
|
||||
filters: &'a [String],
|
||||
) {
|
||||
if filters.is_empty() {
|
||||
return;
|
||||
}
|
||||
builder.push(" AND (");
|
||||
for (idx, filter) in filters.iter().enumerate() {
|
||||
if idx > 0 {
|
||||
builder.push(" OR ");
|
||||
}
|
||||
builder
|
||||
.push(column)
|
||||
.push(" LIKE '%' || ")
|
||||
.push_bind(filter.as_str())
|
||||
.push(" || '%'");
|
||||
}
|
||||
builder.push(")");
|
||||
}
|
||||
|
||||
async fn open_sqlite(path: &Path) -> anyhow::Result<SqlitePool> {
|
||||
let options = SqliteConnectOptions::new()
|
||||
.filename(path)
|
||||
|
||||
Reference in New Issue
Block a user