Skip to content

Commit

Permalink
Merge pull request #122 from pamburus/feature/time-filter
Browse files Browse the repository at this point in the history
new: Improved performance of `since` and `until` filters in `sort` mode
  • Loading branch information
pamburus authored Jan 27, 2024
2 parents de652ab + a579414 commit 9f51a7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ categories = ["command-line-utilities"]
description = "Utility for viewing json-formatted log files."
keywords = ["cli", "human", "log"]
name = "hl"
version = "0.25.0"
version = "0.25.1-beta.1"
edition = "2021"
build = "build.rs"

Expand Down
26 changes: 19 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,27 @@ impl App {
if src.stat.lines_valid == 0 {
return None;
}
if let Some(level) = self.options.filter.level {
if !src.match_level(level) {
return None;
if let Some((ts_min, ts_max)) = src.stat.ts_min_max {
if let Some(until) = self.options.filter.until {
if ts_min > until.into() {
return None;
}
}
if let Some(since) = self.options.filter.since {
if ts_max < since.into(){
return None;
}
}
if let Some(level) = self.options.filter.level {
if !src.match_level(level) {
return None;
}
}
let offset = block.offset();
Some((block, ts_min, ts_max, i, offset))
} else {
None
}
let offset = block.offset();
src.stat
.ts_min_max
.map(|(ts_min, ts_max)| (block, ts_min, ts_max, i, offset))
})
.collect();

Expand Down

0 comments on commit 9f51a7c

Please sign in to comment.