From cb4c18b107499b8db40ba07425f3790ca89ab7a8 Mon Sep 17 00:00:00 2001 From: dualfroz Date: Wed, 2 Sep 2026 09:42:40 +0200 Subject: [PATCH] fix(client): correct not-equal date filter in status query When filtering `pueue status` with a bare date and the `!=` operator (e.g. `end!=2022-01-10`), the generated predicate was `field < start_of_day && field > end_of_day`. A timestamp can never be both before the start and after the end of the same day, so the filter always evaluated to false and silently dropped every task. Use `||` so a task matches when its timestamp lies outside the given day, mirroring the `lt`/`gt` branches for the same column. --- pueue/src/client/commands/state/query/filters.rs | 2 +- pueue/src/client/commands/state/query/mod.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pueue/src/client/commands/state/query/filters.rs b/pueue/src/client/commands/state/query/filters.rs index 30cce56..ae59cc1 100644 --- a/pueue/src/client/commands/state/query/filters.rs +++ b/pueue/src/client/commands/state/query/filters.rs @@ -169,7 +169,7 @@ pub fn datetime(section: Pair<'_, Rule>, query_result: &mut QueryResult) -> Resu match operator { Rule::eq => field > start_of_day && field < end_of_day, - Rule::neq => field < start_of_day && field > end_of_day, + Rule::neq => field < start_of_day || field > end_of_day, Rule::lt => field < start_of_day, Rule::gt => field > end_of_day, _ => true, diff --git a/pueue/src/client/commands/state/query/mod.rs b/pueue/src/client/commands/state/query/mod.rs index ab6d8a7..632e6e8 100644 --- a/pueue/src/client/commands/state/query/mod.rs +++ b/pueue/src/client/commands/state/query/mod.rs @@ -384,6 +384,21 @@ mod test { Ok(()) } + /// Filter by end date using the not-equal operator. + /// A `column != date` filter must keep every task whose end lies outside of that day. + #[rstest] + #[case("2022-01-10", 1)] + #[case("2022-01-08", 0)] + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn filter_end_neq_date(#[case] date: &str, #[case] expected_id: usize) -> Result<()> { + let tasks = test_tasks_with_query(&format!("end!={date}"), &None)?; + + assert_eq!(tasks.len(), 1); + assert_eq!(tasks[0].id, expected_id); + + Ok(()) + } + /// Filter tasks by status #[rstest] #[case("queued", 2)]