Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EES-5405 Stash all release related fields of a data set version in a new Release entity #5157

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

benoutram
Copy link
Collaborator

@benoutram benoutram commented Aug 16, 2024

This PR simplifies Public API endpoints for getting a data set version and listing data set versions by removing the need to make an external call to the Content API to get release file and release information related to data set versions.

The fields currently gathered from the external Content API client call are the File.DataSetFileId, ReleaseVersion.Slug, and ReleaseVersion.Title, all from the content model.

This PR makes a Public Data model change to stash all of these release related fields of a data set version in a new Release owned entity owned by DataSetVersion. Existing field DataSetVersion.ReleaseFileId is also migrated to the new entity.

As well as removing the need for the external call, this change makes getting a data set version compatible with preview tokens in #5133. Attempting to get a data set version with a preview token currently fails due to the Content API not allowing access to unpublished data unless.

This results in one renamed column and three new columns of the DataSetVersion database table:

  • ReleaseFileId -> Release_ReleaseFileId
  • Release_DataSetFileId
  • Release_Slug
  • Release_Title

Admin changes to update a release version

The year and time period of a draft release version can be updated in the Admin which alter the values of slug and title. This means a change has been necessary to the Admin's update release endpoint to keep any data set versions related to the release version indirectly via release files, in sync with the content release version.

Other changes

  • Fix a bug in Admin.Tests.Fixture.IntegrationTestFixture where after clearing test data, tracked entities in ChangeTracker were not cleared. Note, it's important to access the context in the fixture with TestApp.Services.GetRequiredService<PublicDataDbContext>() rather than TestApp.GetDbContext<PublicDataDbContext>() to ensure we get the same Scoped lifetime context instance from the same service provider as used by DI to set up transient services, rather than from a new scope service provider which would create a new context instance where clearing the tracker would have no effect.

  • Reformat Admin.Tests.Services.ReleaseServiceTests, grouping related tests into separate classes.

@benoutram benoutram force-pushed the EES-5405 branch 3 times, most recently from d0ada44 to 88f5a6f Compare August 19, 2024 17:22
.WithRelease(DataFixture.DefaultDataSetVersionRelease()
.WithReleaseFileId(releaseVersion1DataFile.Id)
.WithSlug(releaseVersion1.Slug)
.WithTitle(releaseVersion2.Title));
Copy link
Collaborator

Choose a reason for hiding this comment

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

think this should be WithTitle(releaseVersion1.Title)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot! Fixed now, thanks. 🙂

@jack-hive jack-hive added the do not merge Don't merge just yet label Aug 20, 2024
@benoutram benoutram removed the do not merge Don't merge just yet label Aug 20, 2024
@benoutram benoutram merged commit 992a8f8 into dev Aug 20, 2024
7 checks passed
@benoutram benoutram deleted the EES-5405 branch August 20, 2024 14:43
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