Skip to content

Add date filters to zypper search#648

Open
NeddM wants to merge 4 commits into
openSUSE:masterfrom
NeddM:feature/search-date-filters
Open

Add date filters to zypper search#648
NeddM wants to merge 4 commits into
openSUSE:masterfrom
NeddM:feature/search-date-filters

Conversation

@NeddM

@NeddM NeddM commented May 22, 2026

Copy link
Copy Markdown

Fixes #575

Summary

Adds date-based filters to zypper search:

  • --build-after YYYY-MM-DD
  • --build-before YYYY-MM-DD
  • --install-after YYYY-MM-DD
  • --install-before YYYY-MM-DD

Validation

Built successfully in an openSUSE Tumbleweed container using:

cmake .. -DZYPP_PREFIX=/usr -DCMAKE_INSTALL_PREFIX=/usr -DLIB=lib64
make -j1

Manually validated:

./src/zypper search --help | grep -E "build-after|build-before|install-after|install-before"
./src/zypper search --build-after 01-01-2024 zypper
./src/zypper search --build-after 2024-01-01 zypper

Notes

This PR intentionally limits the initial scope to filtering results only. It does not add new table columns or XML output fields, keeping the change small and easier to review.

@elfring

elfring commented May 24, 2026

Copy link
Copy Markdown

🤔

  • How do you think about to support the filtering of time ranges?
  • Can any time units be selected?

@NeddM

NeddM commented May 24, 2026

Copy link
Copy Markdown
Author

Time ranges are currently supported by combining the after and before options, for example:

zypper search --build-after 2024-01-01 --build-before 2024-12-31 foo
zypper search --install-after 2024-01-01 --install-before 2024-12-31 --installed-only foo

For this first implementation I intentionally limited the accepted input to calendar dates in YYYY-MM-DD format. My idea was to keep the initial scope small and predictable, and avoid adding a more complex relative-time parser in the first PR.

Support for relative units such as days, weeks, or months could be added later if maintainers think that is useful, for example with options like --build-within 30d or similar.

@elfring

elfring commented May 25, 2026

Copy link
Copy Markdown

How do you think about to experiment with an other filter parameter style? 🤔
filter_on installation between 2024-01-01 yesterday

@NeddM

NeddM commented May 25, 2026

Copy link
Copy Markdown
Author

Thanks for the suggestion.

I think an expression-style filter syntax could be interesting, especially if zypper search gets more advanced filtering capabilities in the future.

For this PR, though, I would prefer to keep the interface based on explicit command-line options, for example:

zypper search --install-after 2024-01-01 --install-before 2024-12-31 foo

The reasons are:

  • it follows the existing zypper search option style more closely
  • it is easier to validate and document
  • it keeps this PR small and focused on date filtering
  • it avoids introducing a new mini-language/parser in the initial implementation

Relative dates such as yesterday could be useful, but I think they should probably be considered separately from this first version.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds date-based filtering to zypper search so users can restrict results by build date and/or install date, addressing #575.

Changes:

  • Introduces new zypper search flags: --build-after/--build-before/--install-after/--install-before.
  • Adds ISO date parsing/validation for CLI input and stores date ranges on SearchCmd.
  • Filters query results via a new matchesDateFilters(...) helper across the relevant output paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/commands/search/search.h Adds DateRange state to SearchCmd and declares date-filter helper methods.
src/commands/search/search.cc Implements date parsing, new CLI options, and applies date filtering to search results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/search/search.cc Outdated
Comment thread src/commands/search/search.cc Outdated
Comment thread src/commands/search/search.cc Outdated
Comment thread src/commands/search/search.cc Outdated
Comment thread src/commands/search/search.cc
@NeddM

NeddM commented May 26, 2026

Copy link
Copy Markdown
Author

All the Copilot revisions fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support time-based searches

3 participants