Skip to content

Conversation

@omkar-ethz
Copy link
Member

@omkar-ethz omkar-ethz commented Jan 16, 2026

Description

SciCatProject/scicat-backend-next#2472 changes the sort order of history records - hence reverse them to preserve the newest to oldest behavior on UI in the history table in Lifecycle tab.

Motivation

Background on use case, changes needed

Fixes:

Please provide a list of the fixes implemented in this PR

  • Items added

Changes:

Please provide a list of the changes implemented by this PR

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Bug Fixes:

  • Reverse the flattened history records array returned from the backend so the lifecycle history table continues to display entries from newest to oldest despite the backend returning them oldest to newest.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Relying on reverse() assumes the backend will always return records in strictly ascending time order; consider sorting explicitly by a timestamp field instead of depending on backend ordering semantics.
  • To make the intent clearer and avoid the somewhat obscure [].concat(...history) pattern, consider using history.flat().reverse() (or history.flatMap(x => x) if targeting older TS support).
  • It might be worth adding a brief code comment where the reversal is done to explain that this compensates for the backend’s oldest-to-newest ordering, so future changes to the API don’t accidentally remove or duplicate the behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Relying on `reverse()` assumes the backend will always return records in strictly ascending time order; consider sorting explicitly by a timestamp field instead of depending on backend ordering semantics.
- To make the intent clearer and avoid the somewhat obscure `[].concat(...history)` pattern, consider using `history.flat().reverse()` (or `history.flatMap(x => x)` if targeting older TS support).
- It might be worth adding a brief code comment where the reversal is done to explain that this compensates for the backend’s oldest-to-newest ordering, so future changes to the API don’t accidentally remove or duplicate the behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

2 participants