Skip to content

Conversation

@omkar-ethz
Copy link
Member

@omkar-ethz omkar-ethz commented Oct 14, 2025

Description

Add history array to v3/datasets response, with the same format as backend-v3. The main difference between GenericHistory and HistoryClass format is that in the former, changed fields are grouped into before and after. Whereas in the latter, each field is present at the top level with field: {previousValue: ..., currentValue: ...}.

Another difference is with Delta strategy, the current history implementation only records fields that are acutally changed. Whereas in old backend, for Dataset.datasetlifecycle, all fields from previous value of datasetlifecyle were recorded in previousValue.

Motivation

Archive/retrieve workflows at PSI depend on backend-v3 representation of History

Fixes

Changes:

  • Created adapter from GenericHistory to HistoryClass
  • Created adapter from (GenericHistory[], Dataset) -> HistoryClass[] that preserves older datasetlifecycle in previousValue

Tests included

  • Included for each change/fix?
  • Passing?

Documentation

  • swagger documentation updated (required for API changes) - auto updated OutputDatasetObsoleteDto to include the history[] array.
  • official documentation updated

Sample output

GET /datasets/{pid}
{
...
  "principalInvestigator": "[email protected]",
  "history": [
    {
      "updatedAt": "2025-10-14T08:05:10.202Z",
      "updatedBy": "ingestor",
      "_id": "",
      "keywords": {
        "previousValue": [
          "new",
          "keyword"
        ],
        "currentValue": [
          "new",
          "keyword",
          "trois"
        ]
      },
      "description": {
        "previousValue": "This is a test description just for change",
        "currentValue": "one last test description"
      }
    },
    {
      "updatedAt": "2025-10-14T07:37:04.757Z",
      "updatedBy": "ingestor",
      "_id": "",
      "isPublished": {
        "previousValue": true,
        "currentValue": false
      }
    },
    {
      "updatedAt": "2025-10-14T07:23:28.580Z",
      "updatedBy": "ingestor",
      "_id": "",
      "keywords": {
        "previousValue": [],
        "currentValue": [
          "new",
          "keyword"
        ]
      },
      "description": {
        "previousValue": "This is a test description what noooo",
        "currentValue": "This is a test description just for change"
      }
    },
    {
      "updatedAt": "2025-10-14T07:15:34.684Z",
      "updatedBy": "ingestor",
      "_id": "",
      "description": {
        "previousValue": "This is a test description back on v3-history",
        "currentValue": "This is a test description what noooo"
      }
    },
    {
      "updatedAt": "2025-10-14T07:15:24.809Z",
      "updatedBy": "ingestor",
      "_id": ""
    },
    {
      "updatedAt": "2025-10-14T07:00:24.262Z",
      "updatedBy": "ingestor",
      "_id": "",
      "keywords": {
        "previousValue": [
          "newtag"
        ],
        "currentValue": []
      },
      "description": {
        "previousValue": "This is a test description hello HEAD^2",
        "currentValue": "This is a test description back on v3-history"
      }
    },
    {
      "updatedAt": "2025-10-14T06:57:00.237Z",
      "updatedBy": "ingestor",
      "_id": "",
      "keywords": {
        "previousValue": [],
        "currentValue": [
          "newtag"
        ]
      }
    },
    {
      "updatedAt": "2025-10-14T06:56:44.914Z",
      "updatedBy": "ingestor",
      "_id": "",
      "description": {
        "previousValue": "This is a test description hello",
        "currentValue": "This is a test description hello HEAD^2"
      }
    },
    {
      "updatedAt": "2025-10-13T13:59:47.634Z",
      "updatedBy": "ingestor",
      "_id": ""
    },
    {
      "updatedAt": "2025-10-13T13:59:17.508Z",
      "updatedBy": "ingestor",
      "_id": "",
      "description": {
        "previousValue": "This is a test description hola",
        "currentValue": "This is a test description hello"
      }
    },
    {
      "updatedAt": "2025-10-13T13:57:50.173Z",
      "updatedBy": "ingestor",
      "_id": "",
      "description": {
        "previousValue": "This is a test description hello",
        "currentValue": "This is a test description hola"
      }
    }
  ]
}

@omkar-ethz omkar-ethz force-pushed the v3-history branch 2 times, most recently from 3cff98a to 542320d Compare October 14, 2025 09:12
@omkar-ethz omkar-ethz marked this pull request as ready for review October 14, 2025 09:25
@omkar-ethz omkar-ethz requested a review from a team as a code owner October 14, 2025 09:25
Copy link
Member

@minottic minottic left a comment

Choose a reason for hiding this comment

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

thanks! minor comments, LGTM otherwise.

I think a class transformer would have been better suited by I see that we are already using these convertors throughout the code


const IGNORE_FIELDS = ["updatedAt", "updatedBy", "_id"];

export function convertObsoleteHistoryToGenericHistory(
Copy link
Member

Choose a reason for hiding this comment

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

is this used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be used in the up migration script: afbb56d, creating a PR soon

Copy link
Member Author

Choose a reason for hiding this comment

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

Migration script PR: #2286

Copy link
Member

Choose a reason for hiding this comment

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

could you please move it in the migration PR then? I am not sure I agree too much with the migration one, but we could merge this one in the meantime if this was part of the other PR


const IGNORE_FIELDS = ["updatedAt", "updatedBy", "_id"];

export function convertObsoleteHistoryToGenericHistory(
Copy link
Member

Choose a reason for hiding this comment

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

could you please move it in the migration PR then? I am not sure I agree too much with the migration one, but we could merge this one in the meantime if this was part of the other PR

@omkar-ethz
Copy link
Member Author

@minottic sure, moved the obsolete-to-generic function in migration PR #2286

Copy link
Member

@minottic minottic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@omkar-ethz omkar-ethz merged commit 624d42c into master Oct 16, 2025
13 checks passed
@omkar-ethz omkar-ethz deleted the v3-history branch October 16, 2025 09:29
@omkar-ethz omkar-ethz mentioned this pull request Oct 17, 2025
4 tasks
github-merge-queue bot pushed a commit that referenced this pull request Oct 17, 2025
<!--
Follow semantic-release guidelines for the PR title, which is used in
the changelog.

Title should follow the format `<type>(<scope>): <subject>`, where
- Type is one of:
build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|BREAKING
CHANGE
- Scope (optional) describes the place of the change (eg a particular
milestone) and is usually omitted
- subject should be a non-capitalized one-line description in present
imperative tense and not ending with a period

See
https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines
for more details.
-->

## Description
<!-- Short description of the pull request -->
Creating a release to generate typescript sdk artifiacts, as
`OutputDatasetObsoleteDto` and `HistoryClass` (used in the frontend) has
changed (OutputDatasetObsoleteDto includes a v3 compatible history
field, and HistoryClass includes an index signature
#2282)

## Motivation
<!-- Background on use case, changes needed -->

## Fixes
<!-- Please provide a list of the issues fixed by this PR -->

* Bug fixed (#X)

## 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 tests pass -->

## Documentation
- [ ] swagger documentation updated (required for API changes)
- [ ] official documentation updated

### official documentation info
<!-- If you have updated the official documentation, please provide PR #
and URL of the updated pages -->
omkar-ethz added a commit to SciCatProject/frontend that referenced this pull request Oct 20, 2025
## Description
As the new backend did not implemet history[] in /v3/datasets, history
was turned off / commented out in
#2041. Uncommented and
fixed type errors (some errors are automatically fixed by using the
v4.24.5 of scicat-sdk-ts-angular which includes
`ObsoleteDatasetOutputDto` with history field), as support for legacy
history was added in
SciCatProject/scicat-backend-next#2282

## Motivation


## Fixes:


## Changes:


## Tests included
- [x] Included for each change/fix?
- [x] 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
- [x] Does it require a specific version of the backend
- which version of the backend is required: v4.24.5

## Screenshot
<img width="819" height="565" alt="history"
src="https://github.com/user-attachments/assets/d06379a2-e137-4f70-a8eb-0367c49971bb"
/>

## Summary by Sourcery

Enable dataset history in the lifecycle tab by updating the SDK version,
adding a custom type for history properties, reactivating the
parseHistoryItems method, and updating the corresponding unit test.

New Features:
- Restore and display dataset history entries in the lifecycle tab

Enhancements:
- Upgrade scicat-sdk-ts-angular to v4.25.0 to include history in
ObsoleteDatasetOutputDto
- Add HistoryWithProperties type to support dynamic history fields in
parsing logic

Tests:
- Un-comment and adapt the unit test for parseHistoryItems in
DatasetLifecycleComponent
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