Skip to content

fix(hardware): allow details URLs without timestamps - #2117

Open
alanpeixinho wants to merge 2 commits into
kernelci:mainfrom
profusion:fix/hardware-optional-timestamps
Open

alanpeixinho wants to merge 2 commits into
kernelci:mainfrom
profusion:fix/hardware-optional-timestamps

Conversation

@alanpeixinho

@alanpeixinho alanpeixinho commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What it is

Hardware details no longer require st/et in the URL. A bare /hardware/<id> uses a rolling window: end = start of tomorrow, start = end minus intervalInDays (URL i, default 5). Listing and details share the same resolver, so counts stay aligned when you change i (for example ?i=100 on listing) without freezing timestamps in the URL. Bookmarked URLs that already include st/et still work.

Closes #2110

How to test

  • Open /hardware/<id> with no st/et or i. Page loads; API uses about 5 days ending at start of tomorrow.
  • On /hardware?i=100, click a platform. Details URL has i=100, no st/et; listing and details requests use the same about 100-day span.
  • Open a details URL that already has st/et. That window is preserved.

Comment on lines +43 to +52
def _lab_from_test(test: Tests) -> str | None:
ingester_lab = getattr(test, "_lab_name", None)
if ingester_lab:
return ingester_lab
lab_fk = getattr(test, "lab", None)
if lab_fk is not None:
return lab_fk.name
# TODO remove misc->>'runtime' fallback after lab backfill
misc = test.misc or {}
return misc.get("runtime")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure this belongs here. making st/et optional doesn't need the lab fk fallback, or rewriting seed start_time to now.

the crash fix looks real, but it'd be easier to review/revert as its own PR (or at least mention it in the description)

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.

Thanks for pointing, this was left from local tests, and I will move to a separate PR.

Comment on lines +14 to +21
const end =
endTimestampInSeconds ?? dateObjectToTimestampInSeconds(startOfTomorrow());

return {
startTimestampInSeconds:
startTimestampInSeconds ?? end - daysToSeconds(intervalInDays),
endTimestampInSeconds: end,
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a bit asymmetric. if only et is in the url, start is et - interval, but if only st is there, end becomes tomorrow instead of st + interval.

so a url that keeps an old st and drops et can turn into a huge window. maybe require both, or derive the missing one from whichever is present

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.

Nice catch

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.

resolveHardwareTimeRange now treats a single bound as an interval-sized window.

  • both st and et: use them as-is (existing bookmarks stay frozen)
  • only et: st = et − intervalInDays
  • only st: et = st + intervalInDays
  • neither: rolling [tomorrow − interval, tomorrow)

@alanpeixinho
alanpeixinho marked this pull request as ready for review September 18, 2026 13:55
* Make st/et optional on hardware details; default window is [tomorrow − iv, tomorrow]
* Share that window between listing and details so counts stay aligned
* Omit st/et from listing and test-detail links unless a revision is pinned
* Link test hardware from platform/compatibles, not the Unknown label
* Read lab from the test FK in aggregation backfill so ORM replays do not crash
* Stamp seed start_time to now so local fixtures land in the default window

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
* Derive the missing bound from whichever of st/et is present, so a URL
  with a stale st no longer widens the window to [st, tomorrow]
* Drop the aggregation lab FK fallback and the seed start_time rewrite;
  neither is needed for optional st/et, and moving fixture start_time to
  now broke integration tests that pin historical timestamps

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
@alanpeixinho
alanpeixinho force-pushed the fix/hardware-optional-timestamps branch from 1335b06 to 6a6e357 Compare September 23, 2026 12:58

This branch has not been deployed

No deployments
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.

Allow Hardware devices to be linkable directly (without timestamp)

2 participants