Skip to content

Commit 3aef22b

Browse files
committed
fix(date-range): Fix issues with date filters
1 parent 9b52132 commit 3aef22b

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src-tauri/src/journal.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl Journal {
7575
sd_journal_seek_tail(self.ptr)?;
7676
}
7777

78-
if q.reset_position && q.no_more_recent_than_epoch > 0 {
79-
sd_journal_seek_realtime_usec(self.ptr, q.no_more_recent_than_epoch)?;
78+
if q.reset_position && q.date_less_than > 0 {
79+
sd_journal_seek_realtime_usec(self.ptr, q.date_less_than)?;
8080
}
8181

8282
let mut count: u64 = 0;
@@ -112,8 +112,8 @@ impl Journal {
112112
break;
113113
}
114114

115-
if q.not_older_than_epoch > 0 && q.not_older_than_epoch >= last_timestamp {
116-
debug!("Reached epoch time of {}", q.not_older_than_epoch);
115+
if q.date_more_than > 0 && q.date_more_than >= last_timestamp {
116+
debug!("Reached epoch time of {}", q.date_more_than);
117117
break;
118118
}
119119

src-tauri/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ async fn get_logs(
106106
let date_to = DateTime::parse_from_rfc3339(&query.datetime_to).ok();
107107

108108
if let Some(x) = date_from {
109-
q.with_date_not_more_recent_than(x.timestamp_micros() as u64);
110-
} else {
111-
let datetime_to = Utc::now() - Duration::days(1);
112-
q.with_date_not_more_recent_than(datetime_to.timestamp_micros() as u64);
109+
q.with_date_more_than(x.timestamp_micros() as u64);
113110
}
114111

115112
if let Some(x) = date_to {
116-
q.with_date_not_older_than(x.timestamp_micros() as u64);
113+
q.with_date_less_than(x.timestamp_micros() as u64);
114+
} else {
115+
let datetime_to = Utc::now() + Duration::days(1);
116+
q.with_date_less_than(datetime_to.timestamp_micros() as u64);
117117
}
118118

119119
let q = q.build();
@@ -159,14 +159,14 @@ async fn get_summary(query: SummaryQuery) -> Result<JournalEntries, JournalError
159159
)
160160
.unwrap();
161161

162-
let datetime_to = Utc::now() - Duration::days(5);
163-
let datetime_from = Utc::now() + Duration::days(1);
162+
let datetime_from = Utc::now() - Duration::days(5);
163+
let datetime_to = Utc::now() + Duration::days(1);
164164
let mut qb = QueryBuilder::default();
165165
let q = qb
166166
.with_fields(vec!["__REALTIME".into()])
167167
.with_limit(10_000)
168-
.with_date_not_older_than(datetime_to.timestamp_micros() as u64)
169-
.with_date_not_more_recent_than(datetime_from.timestamp_micros() as u64)
168+
.with_date_more_than(datetime_from.timestamp_micros() as u64)
169+
.with_date_less_than(datetime_to.timestamp_micros() as u64)
170170
.with_priority_above_or_equal_to(query.priority)
171171
.build();
172172

src-tauri/src/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ pub struct Query {
66
pub(crate) units: Vec<String>,
77
pub(crate) slice: String,
88
pub(crate) limit: u64,
9-
pub(crate) no_more_recent_than_epoch: u64,
10-
pub(crate) not_older_than_epoch: u64,
9+
pub(crate) date_less_than: u64,
10+
pub(crate) date_more_than: u64,
1111
pub(crate) transports: Vec<String>,
1212
pub(crate) quick_search: String,
1313
pub(crate) reset_position: bool,

src-tauri/src/query_builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ impl QueryBuilder {
1717
boot_ids: vec![],
1818
limit: 100,
1919
transports: vec!["syslog".into(), "journal".into(), "stdout".into()],
20-
no_more_recent_than_epoch: 0,
21-
not_older_than_epoch: 0,
20+
date_less_than: 0,
21+
date_more_than: 0,
2222
quick_search: "".into(),
2323
reset_position: true,
2424
};
@@ -84,13 +84,13 @@ impl QueryBuilder {
8484
self
8585
}
8686

87-
pub fn with_date_not_more_recent_than(&mut self, from_epoch: u64) -> &mut Self {
88-
self.query.no_more_recent_than_epoch = from_epoch;
87+
pub fn with_date_less_than(&mut self, from_epoch: u64) -> &mut Self {
88+
self.query.date_less_than = from_epoch;
8989
self
9090
}
9191

92-
pub fn with_date_not_older_than(&mut self, to_epoch: u64) -> &mut Self {
93-
self.query.not_older_than_epoch = to_epoch;
92+
pub fn with_date_more_than(&mut self, to_epoch: u64) -> &mut Self {
93+
self.query.date_more_than = to_epoch;
9494
self
9595
}
9696

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function quickSearch(search: string) {
9696
}
9797
9898
function toggleTheme() {
99-
vm.theme == "dark" ? vm.theme = "" : vm.theme = "dark"
99+
vm.theme == "dark" ? (vm.theme = "") : (vm.theme = "dark");
100100
}
101101
102102
function filter(filter: Filter) {

0 commit comments

Comments
 (0)