-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from DFE-Digital/development
Release v2.5.0
- Loading branch information
Showing
45 changed files
with
3,070 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule contentandsupport
updated
75 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# 0037 - Content Validation Process | ||
|
||
* **Status**: proposed | ||
|
||
## Context and Problem Statement | ||
|
||
Certain fields in Contentful are mandatory, and we currently do not save any content items which are invalid, due to missing such fields. | ||
This poses a problem with the following content creation process: | ||
1. A question is created and details filled in | ||
2. A new answer is added to that question | ||
3. The answer is incomplete, so invalid, so doesn't save | ||
4. Therefore no question -> answer relationship is saved | ||
5. The answer is filled in | ||
6. It then gets saved to the db on its own | ||
7. the question -> answer relationship was never re-attempted, so still does not exist | ||
8. The question then doesn't show this answer in production | ||
|
||
This can be resolved by republishing the question, but it is frustrating for content designers to have to repeatedly republish content. | ||
It also leaves production missing content until someone notices, so we need a way to fix this issue. | ||
|
||
## Decision Drivers | ||
|
||
- Ease of development | ||
- Reliability of the solution | ||
- How testable the solution is | ||
- Minimising risk of error for the function | ||
- Minimising risk of error in the web app | ||
|
||
## Considered Options | ||
|
||
### Overnight/periodic job to run a content validator and retrieve missing items: | ||
|
||
- Pros | ||
- Minimal regression risk to web app as it can stay exactly as is | ||
- Can handle any error that has occured with the function, not just this, including it temporarily going down entirely | ||
- Cons | ||
- In the time between an issue arising and the periodic job running, the app could be broken due to missing relationships, so this may not be adequate | ||
- May be resource intensive if run frequently, as it does full validation | ||
- Requires developing a solution to fix the issues found by the validator and setting up periodic jobs | ||
|
||
### Making all database fields (except primary keys) nullable: | ||
|
||
- Pros | ||
- Robust approach to the problem, it's highly likely to ensure the correct relationships save to the database every time | ||
- Minimal risk of errors within the Azure function | ||
- Cons | ||
- High risk of hitting an error page in the web app when partial content exists, due to it expecting content that isn't there | ||
- Would require extensive testing with partially complete content items to be sure of the web app not breaking | ||
- Widespread changes within the code base, risk of regression | ||
|
||
### Having default values for simple fields, and nullable content references | ||
Not every field can have a default, for instance a question section requires an interstitial page, which cannot be populated with a default value, | ||
but we could make every field that can have a default, have a default and the others nullable. | ||
|
||
- Pros | ||
- Lower risk than making all fields nullable, as it requires fewer changes to the web app | ||
- Also a robust approach that is highly likely to work | ||
- Relatively low risk of errors within the Azure function | ||
- Cons | ||
- May still be quite a few code changes involved in making all content references nullable, with the same risks as the option above (but less widespread) | ||
- Needs careful testing of all types which are made nullable | ||
- The defaults will render incomplete content "valid" when it isn't. This risk is small because Contentful doesn't allow publishing content with missing mandatory fields. So only UsePreview environments have a risk of showing blank content. | ||
|
||
## Decision Outcome | ||
|
||
Option 3. It's lowest risk and involvement whilst effectively resolving the problem. The suggested implementation will be to modify the way the Azure function maps a json object into database entities and add defaults at this stage, to minimise the changes required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ech.DatabaseUpgrader/Scripts/2024/20240827_1056_CreateGetCurrentSubmissionIdProcedure.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE OR ALTER PROCEDURE GetCurrentSubmissionId | ||
@sectionId NVARCHAR(50), | ||
@establishmentId INT, | ||
@submissionId INT OUTPUT | ||
AS | ||
|
||
SELECT @submissionId = ( | ||
SELECT TOP 1 Id | ||
FROM [dbo].[submission] | ||
WHERE completed = 0 | ||
AND deleted = 0 | ||
AND sectionId = @sectionId | ||
AND establishmentId = @establishmentId | ||
ORDER BY dateCreated DESC | ||
) |
29 changes: 29 additions & 0 deletions
29
...DatabaseUpgrader/Scripts/2024/20240827_1058_UpdateSelectOrInsertSubmissionIdProcedure.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
ALTER PROCEDURE SelectOrInsertSubmissionId | ||
@sectionId NVARCHAR(50), | ||
@sectionName NVARCHAR(50), | ||
@establishmentId INT, | ||
@submissionId INT OUTPUT | ||
AS | ||
|
||
BEGIN TRY | ||
BEGIN TRAN | ||
EXEC GetCurrentSubmissionId | ||
@sectionid=@sectionId, | ||
@establishmentId=@establishmentId, | ||
@submissionId=@submissionId OUTPUT | ||
|
||
IF @submissionId IS NULL | ||
BEGIN | ||
INSERT INTO [dbo].[submission] | ||
(establishmentId, completed, sectionId, sectionName) | ||
OUTPUT INSERTED.ID | ||
VALUES | ||
(@establishmentId, 0, @sectionId, @sectionName) | ||
|
||
SELECT @submissionId = SCOPE_IDENTITY() | ||
END | ||
COMMIT TRAN | ||
END TRY | ||
BEGIN CATCH | ||
ROLLBACK TRAN | ||
END CATCH |
25 changes: 25 additions & 0 deletions
25
...ch.DatabaseUpgrader/Scripts/2024/20240827_1102_UpdateDeleteCurrentSubmissionProcedure.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE OR ALTER PROCEDURE DeleteCurrentSubmission | ||
@sectionId NVARCHAR(50), | ||
@sectionName NVARCHAR(50), | ||
@establishmentId INT | ||
AS | ||
BEGIN TRY | ||
DECLARE @submissionId INT | ||
|
||
EXEC GetCurrentSubmissionId | ||
@sectionid=@sectionId, | ||
@establishmentId=@establishmentId, | ||
@submissionId=@submissionId OUTPUT | ||
|
||
BEGIN TRAN | ||
UPDATE S | ||
SET deleted = 1 | ||
FROM [dbo].[submission] S | ||
WHERE S.id = @submissionId | ||
COMMIT TRAN | ||
|
||
END TRY | ||
BEGIN CATCH | ||
ROLLBACK TRAN | ||
END CATCH | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Dfe.PlanTech.Domain/Submissions/Models/SectionStatusDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Dfe.PlanTech.Domain.Submissions.Models; | ||
|
||
public class SectionStatusDto | ||
{ | ||
public string SectionId { get; set; } = null!; | ||
|
||
public bool Completed { get; set; } | ||
|
||
public string? LastMaturity { get; set; } | ||
|
||
public DateTime DateCreated { get; set; } | ||
|
||
public DateTime DateUpdated { get; set; } | ||
} |
Oops, something went wrong.