Skip to content

feat: add date filter#1834

Open
dede999 wants to merge 14 commits intokernelci:mainfrom
profusion:feat/add_date_filter
Open

feat: add date filter#1834
dede999 wants to merge 14 commits intokernelci:mainfrom
profusion:feat/add_date_filter

Conversation

@dede999
Copy link
Copy Markdown
Contributor

@dede999 dede999 commented Mar 31, 2026

Description

This PR adds the feature of querying issues by start and end dates

  • You can't select a future date as you ending (most recent) date
  • You can't select an end date happening before your start (less recent) date
  • You can't select a starting date after the end date

How to Test

You have some ways to test it:

  • By visiting http://localhost:5173/issues and checking these behaviors
  • By visiting http://localhost:5173/issues?et=1774915200&st=1772323200 and checking if the dates are March 1st and 31st 2026

Related issue

Closes #1784

@dede999 dede999 marked this pull request as draft March 31, 2026 20:07
@dede999 dede999 force-pushed the feat/add_date_filter branch from 0a00c87 to 371e8be Compare March 31, 2026 20:13
@MarceloRobert MarceloRobert added Backend Most or all of the changes for this issue will be in the backend code. Frontend Most or all of the changes for this issue will be in the frontend code. labels Apr 1, 2026
@dede999 dede999 force-pushed the feat/add_date_filter branch from 371e8be to faf3486 Compare April 1, 2026 15:51
@dede999 dede999 force-pushed the feat/add_date_filter branch 2 times, most recently from 14d25f7 to 38050d4 Compare April 2, 2026 11:10
@dede999 dede999 force-pushed the feat/add_date_filter branch from e590f37 to 5a3425b Compare April 2, 2026 12:53
@dede999 dede999 marked this pull request as ready for review April 2, 2026 13:17
@dede999 dede999 force-pushed the feat/add_date_filter branch 2 times, most recently from e5252a7 to eea4e27 Compare April 2, 2026 15:07

Raises ValueError if the timestamp strings are not valid numbers.
"""
if start_timestamp is not None and end_timestamp is not None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what if only one of the parameters is not None? Ex.: in case start_timestamp is 10 days ago and end_timestamp is None. From what I can see the start_timestamp would be overwritten to 7 days ago

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have improved that by setting default values, and no overriding now. Thanks

Copy link
Copy Markdown
Contributor

@alanpeixinho alanpeixinho left a comment

Choose a reason for hiding this comment

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

Looks good.
Had a small issue on firefox (only on touch mode), where the calendar may not be clickable on small screen. The ideal would be to test on a phone.
On chrome it is okay though.

Image

"start_timestamp, end_timestamp, status_code, has_error_body",
[
(_TS_START, _TS_END, HTTPStatus.OK, False),
("not_a_number", _TS_END, HTTPStatus.BAD_REQUEST, True),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we include invalid end_timestamp on test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And I did

const fetchIssueListing = async ({
intervalInDays,
const getDefaultEndTimestamp = (): number =>
dateObjectToTimestampInSeconds(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need time? cant we round to start/end of day?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll take a few minutes to try it. It seems very legitm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

type: object
description: Optional filter dictionary for additional query parameters
- in: query
name: interval_in_days
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we remove this parameter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Gotta check that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@dede999 run the generate-schema.sh to update the schema automatically

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just added the change to the PR. You can check it again

Comment on lines -69 to -73
-5,
None,
None,
HTTPStatus.BAD_REQUEST,
True,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why remove this test case?

Copy link
Copy Markdown
Contributor Author

@dede999 dede999 Apr 6, 2026

Choose a reason for hiding this comment

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

It was removed, because the behavior was modified. Now there are default values for start and end values

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

even if there are defaults, a user could make a manual request with the wrong values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which is checked on the test below

@MarceloRobert MarceloRobert added the enhancement New feature or request label Apr 6, 2026
@dede999 dede999 force-pushed the feat/add_date_filter branch 5 times, most recently from a6bde1e to cc4ec2e Compare April 7, 2026 14:44
Copy link
Copy Markdown
Collaborator

@MarceloRobert MarceloRobert left a comment

Choose a reason for hiding this comment

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

Looks good, there's just a problem in the frontend in case the user tries to type in a small year such as "25" instead of "2025"

dede999 added 4 commits April 8, 2026 12:16
Add support for explicit start/end Unix timestamp parameters to the
api/issue listing endpoints, mirroring the existing behaviour of the
api/hardware view.

Unit and integration tests updated and extended with timestamp-based
test cases and an invalid-timestamp error case.
Replace interval_in_days + starting_date with start/end timestamp
parameters throughout test fixtures and client helpers. Use dynamic
timestamps computed at runtime so tests don't go stale.
Replace the single `intervalInDays` URL param with optional
`startTimestampInSeconds` and `endTimestampInSeconds` params in the
issues route. Restrict InputTime to routes that still use intervalInDays
and swap the time input for the new DateRangeInput component.
Add a date range picker with two native date inputs for the issues
listing page. Invalid selections (end before start) show an inline error
with a red border and a message below the inputs, clearing after 3s.
dede999 and others added 10 commits April 8, 2026 12:16
Replace interval_in_days + starting_date_iso_format params with direct
startTimestampInSeconds and endTimestampInSeconds, matching the new
backend contract. Defaults to last 5 days when params are absent from URL.
Test that the fetch function sends startTimestampInSeconds and
endTimestampInSeconds to /api/issue/, includes backend-compatible
filter params, returns the API response, and propagates errors.
Cover page load, date range input defaults, start/end date URL updates,
validation preventing end-before-start navigation, table size change,
pagination, and row visibility.

� The commit message kernelci#2 will be skipped:

� fixup! test(issues): add E2E tests for issue listing page
This is made by stabilizing queryKey with `roundToNearestMinutes`, and
it was a crucial change as iyt might have overloaded the backend with
unnecessary queries
- Rename TEN_DAYS to ISO_DATE_LENGTH (10) for clarity
- Add ONE_DAY constant for yesterday date calculation
- Fix end date test to use yesterday instead of a future date
- Fix table size option from '25' (non-existent) to '20'
- Remove unused startValue variable in end-date test

Closes kernelci#1784
10 tests covering: defaults, explicit timestamps, partial args,
start > end validation, float timestamps, invalid inputs,
equal timestamps, and UTC timezone enforcement.

Moreover, some changes were brought to the date range. to simplify it
and treat some cases that one or another timestamp might not be
provided.
start_date now defaults to end_date - 7d instead of now() - 7d, so
an API call with only a past end_timestamp no longer raises ValueError.
A future-only start still correctly raises since end defaults to now().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… error map

- Export MILLISECONDS_IN_ONE_SECOND from utils/date and reuse it
- Replace template literal classNames with cn() utility
- Type errorMessageIds with MessageDescriptor['id']
- Bump error message text size from xs to sm

Closes kernelci#1784
@dede999 dede999 force-pushed the feat/add_date_filter branch from cc4ec2e to 249edbe Compare April 8, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Most or all of the changes for this issue will be in the backend code. enhancement New feature or request Frontend Most or all of the changes for this issue will be in the frontend code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filters to issues-list that match the query used in the weekly-report

3 participants