优化错误报告列表分页
无过滤列表改用 created_at BTree 索引读取 保留过滤查询语义并减少全量排序开销
This commit is contained in:
@@ -293,6 +293,25 @@ pub fn list_error_reports_and_return(
|
||||
crate::editor_project_storage::require_editor_generation_runtime_service_identity(
|
||||
tx, caller,
|
||||
)?;
|
||||
let limit = input.limit.clamp(1, 500) as usize;
|
||||
let offset = input.offset as usize;
|
||||
if input.status.is_none() && input.fingerprint.is_none() && input.source.is_none() {
|
||||
let mut rows = tx
|
||||
.db
|
||||
.error_report()
|
||||
.by_error_report_created_at()
|
||||
.filter(Timestamp::from_micros_since_unix_epoch(i64::MIN)..)
|
||||
.collect::<Vec<_>>();
|
||||
let total = rows.len() as u64;
|
||||
rows.reverse();
|
||||
let reports = rows
|
||||
.into_iter()
|
||||
.skip(offset)
|
||||
.take(limit)
|
||||
.map(|row| snapshot(&row))
|
||||
.collect::<Vec<_>>();
|
||||
return Ok((reports, total));
|
||||
}
|
||||
let mut rows = tx
|
||||
.db
|
||||
.error_report()
|
||||
@@ -323,8 +342,6 @@ pub fn list_error_reports_and_return(
|
||||
.then_with(|| right.batch_id.cmp(&left.batch_id))
|
||||
});
|
||||
let total = rows.len() as u64;
|
||||
let limit = input.limit.clamp(1, 500) as usize;
|
||||
let offset = input.offset as usize;
|
||||
let reports = rows
|
||||
.into_iter()
|
||||
.skip(offset)
|
||||
|
||||
Reference in New Issue
Block a user