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-5707 Remove geojson cache file after updating data block with map #5516

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using GovUk.Education.ExploreEducationStatistics.Admin.Cache;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Cache;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Security;
Expand Down Expand Up @@ -217,7 +218,7 @@ public async Task<Either<ActionResult, DataBlockViewModel>> Update(
.OnSuccessDo(dataBlock => _userService.CheckCanUpdateReleaseVersion(dataBlock.ReleaseVersion))
.OnSuccessDo(async dataBlockVersion =>
{
// TODO EES-753 Alter this when multiple charts are supported
// Remove old infographic file if using a new file
var infographicChart = dataBlockVersion.Charts.OfType<InfographicChart>().FirstOrDefault();
var updatedInfographicChart =
updateRequest.Charts.OfType<InfographicChart>().FirstOrDefault();
Expand All @@ -229,6 +230,14 @@ await _releaseFileService.Delete(releaseVersionId: dataBlockVersion.ReleaseVersi
fileId: new Guid(infographicChart.FileId));
}

// If has map chart, remove geojson cache
var mapChart = dataBlockVersion.Charts.OfType<MapChart>().FirstOrDefault();
if (mapChart != null)
{
await _cacheService.DeleteItemAsync(
new LocationsForDataBlockCacheKey(dataBlockVersion, mapChart.BoundaryLevel));
Comment on lines +237 to +238
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering if there are any other places we should be invalidating the geojson cache, like if the data is replaced?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed this with Ben and Cam on Slack. We think the geojson cache isn't being invalidated for replacements, but we think that probably isn't an issue. We decided to not do anything about replacements immediately and highlight this case for testing.

}

_mapper.Map(updateRequest, dataBlockVersion.ContentBlock);

_context.DataBlocks.Update(dataBlockVersion.ContentBlock);
Expand Down
Loading