diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6bfce7f7a0..ebecc1dbfe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,7 +1,7 @@ # CODEOWNERS file for das-assessor-service # The following users will be automatically added as Reviewers to all PRs. -* @ChrisJWoodcock @karen-hanna @LACrossley +* @ChrisJWoodcock @karen-hanna .github/CODEOWNERS @SkillsFundingAgency/das-platform-engineering /azure/ @SkillsFundingAgency/das-platform-engineering diff --git a/src/SFA.DAS.AssessorService.Api.Types/Models/AO/AparSummary.cs b/src/SFA.DAS.AssessorService.Api.Types/Models/AO/AparSummary.cs deleted file mode 100644 index eee24aad27..0000000000 --- a/src/SFA.DAS.AssessorService.Api.Types/Models/AO/AparSummary.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace SFA.DAS.AssessorService.Api.Types.Models.AO -{ - public class AparSummary - { - public string Id { get; set; } - public string Name { get; set; } - public int Ukprn { get; set; } - public DateTime EarliestDateStandardApprovedOnRegister { get; set; } - public DateTime EarliestEffectiveFromDate { get; set; } - } -} diff --git a/src/SFA.DAS.AssessorService.Api.Types/Models/AparSummaryUpdateRequest.cs b/src/SFA.DAS.AssessorService.Api.Types/Models/AparSummaryUpdateRequest.cs deleted file mode 100644 index ebdda520d9..0000000000 --- a/src/SFA.DAS.AssessorService.Api.Types/Models/AparSummaryUpdateRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using MediatR; - -namespace SFA.DAS.AssessorService.Api.Types.Models -{ - public class AparSummaryUpdateRequest : IRequest - { - } -} diff --git a/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryLastUpdatedRequest.cs b/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryLastUpdatedRequest.cs deleted file mode 100644 index e08dd18bda..0000000000 --- a/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryLastUpdatedRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using MediatR; -using System; - -namespace SFA.DAS.AssessorService.Api.Types.Models -{ - public class GetAparSummaryLastUpdatedRequest : IRequest - { - } -} diff --git a/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryRequest.cs b/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryRequest.cs deleted file mode 100644 index edd392819f..0000000000 --- a/src/SFA.DAS.AssessorService.Api.Types/Models/GetAparSummaryRequest.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using MediatR; -using SFA.DAS.AssessorService.Api.Types.Models.AO; - -namespace SFA.DAS.AssessorService.Api.Types.Models -{ - public class GetAparSummaryRequest : IRequest> - { - public int? Ukprn { get; } - - public GetAparSummaryRequest() - { - } - - public GetAparSummaryRequest(int? ukprn) - { - Ukprn = ukprn; - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Command/AparSummaryUpdateTests.cs b/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Command/AparSummaryUpdateTests.cs deleted file mode 100644 index 5d39a60da4..0000000000 --- a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Command/AparSummaryUpdateTests.cs +++ /dev/null @@ -1,61 +0,0 @@ -using AutoFixture.NUnit3; -using FluentAssertions; -using MediatR; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using NUnit.Framework.Internal; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Api.Controllers; -using SFA.DAS.AssessorService.Application.Api.TaskQueue; -using System; -using System.Net; - -namespace SFA.DAS.AssessorService.Application.Api.UnitTests.Controllers.Register.Query -{ - - [TestFixture] - public class AparSummaryUpdateTests - { - private Mock _backgroundTaskQueue; - private Mock _mediator; - private Mock> _logger; - private RegisterQueryController _sut; - - [SetUp] - public void Arrange() - { - _backgroundTaskQueue = new Mock(); - _mediator = new Mock(); - _logger = new Mock>(); - - _sut = new RegisterQueryController(_mediator.Object, _backgroundTaskQueue.Object, _logger.Object); - } - - [Test, AutoData] - public void When_PostToRefreshProvidersCache_Then_BackgroundTaskIsQueued() - { - // Act - var controllerResult = _sut.AparSummaryUpdate() as ObjectResult; - - // Assert - _backgroundTaskQueue.Verify(m => m.QueueBackgroundRequest( - It.IsAny(), - "update APAR summary", - It.IsAny>>()), - Times.Once); - } - - [Test] - public void When_RefreshProvidersCacheHasNoErrors_Then_ReturnsAccepted() - { - // Act - var controllerResult = _sut.AparSummaryUpdate() as ObjectResult; - - // Assert - - controllerResult.StatusCode.Should().Be((int)HttpStatusCode.Accepted); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryLastUpdatedTests.cs b/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryLastUpdatedTests.cs deleted file mode 100644 index 1ac42a2a6c..0000000000 --- a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryLastUpdatedTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -using FluentAssertions; -using MediatR; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Api.Controllers; -using SFA.DAS.AssessorService.Application.Api.TaskQueue; -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.Api.UnitTests.Controllers.Register.Query -{ - public class GetAparSummaryLastUpdatedTests - { - private Mock _mockBackgroundTaskQueue; - private static Mock _mediator; - private static Mock> _logger; - private static RegisterQueryController _sut; - private static object _result; - private static DateTime _expectedLastUpdated; - - [SetUp] - public async Task Arrange() - { - _mockBackgroundTaskQueue = new Mock(); - _mediator = new Mock(); - _logger = new Mock>(); - _expectedLastUpdated = DateTime.UtcNow; - - _mediator.Setup(m => m.Send(It.IsAny(), new CancellationToken())) - .ReturnsAsync(_expectedLastUpdated); - - _sut = new RegisterQueryController(_mediator.Object, _mockBackgroundTaskQueue.Object, _logger.Object); - - _result = await _sut.GetAparSummaryLastUpdated(); - } - - [Test] - public void GetAparSummaryLastUpdated_MediatorShouldSendGetAparSummaryLastUpdatedRequest_WhenCalled() - { - _mediator.Verify(m => m.Send(It.IsAny(), new CancellationToken())); - } - - - [Test] - public void GetAparSummaryLastUpdated_ShouldReturnOk_WhenCalled() - { - _result.Should().BeOfType(); - } - - [Test] - public void GetAparSummaryLastUpdatedy_ResultsAreOfTypeDateTime_WhenCalled() - { - ((OkObjectResult)_result).Value.Should().BeOfType(); - } - - [Test] - public void GetAparSummaryLastUpdated_ResultsMatchExpectedDateTime_WhenCalled() - { - var organisations = ((OkObjectResult)_result).Value as DateTime?; - organisations.Should().Be(_expectedLastUpdated); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryTests.cs b/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryTests.cs deleted file mode 100644 index a719ed10aa..0000000000 --- a/src/SFA.DAS.AssessorService.Application.Api.UnitTests/Controllers/Register/Query/GetAparSummaryTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using FluentAssertions; -using MediatR; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using NUnit.Framework.Internal; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Api.Types.Models.AO; -using SFA.DAS.AssessorService.Application.Api.Controllers; -using SFA.DAS.AssessorService.Application.Api.TaskQueue; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.Api.UnitTests.Controllers.Register.Query -{ - - [TestFixture] - public class GetAparSummaryTests - { - private Mock _backgroundTaskQueue; - private Mock _mediator; - private Mock> _logger; - private RegisterQueryController _sut; - private object _result; - - private List _expectedAparSummaries; - private AparSummary _aparSummary1; - private AparSummary _aparSummary2; - - [SetUp] - public async Task Arrange() - { - _backgroundTaskQueue = new Mock(); - _mediator = new Mock(); - _logger = new Mock>(); - _aparSummary1 = new AparSummary { Id = "EPA0001", Name = "Name 1", Ukprn = 1111111, - EarliestDateStandardApprovedOnRegister = DateTime.Today, EarliestEffectiveFromDate = DateTime.Today.AddDays(-1) }; - _aparSummary2 = new AparSummary { Id = "EPA0002", Name = "Name 2", Ukprn = 2222222, - EarliestDateStandardApprovedOnRegister = DateTime.Today, EarliestEffectiveFromDate = DateTime.Today.AddMonths(-1) }; - - _expectedAparSummaries = new List - { - _aparSummary1, - _aparSummary2 - }; - - _mediator.Setup(m => - m.Send(It.IsAny(), - new CancellationToken())).ReturnsAsync(_expectedAparSummaries); - _sut = new RegisterQueryController(_mediator.Object, _backgroundTaskQueue.Object, _logger.Object); - - _result = await _sut.GetAparSummary(); - } - - [Test] - public void GetAparSummary_MediatorShouldSendGetAparSummaryRequest_WhenCalled() - { - _mediator.Verify(m => m.Send(It.IsAny(), new CancellationToken())); - } - - - [Test] - public void GetAparSummary_ShouldReturnOk_WhenCalled() - { - _result.Should().BeOfType(); - } - - [Test] - public void GetAparSummary_ResultsAreOfTypeListAparSummary_WhenCalled() - { - ((OkObjectResult)_result).Value.Should().BeOfType>(); - } - - [Test] - public void GetAparSummary_ResultsMatchExpectedListAparSummary_WhenCalled() - { - var organisations = ((OkObjectResult)_result).Value as List; - organisations.Count.Should().Be(2); - organisations.Should().Contain(_aparSummary1); - organisations.Should().Contain(_aparSummary2); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.Api/Controllers/RegisterQueryController.cs b/src/SFA.DAS.AssessorService.Application.Api/Controllers/RegisterQueryController.cs index 567e9370e7..83efb3237a 100644 --- a/src/SFA.DAS.AssessorService.Application.Api/Controllers/RegisterQueryController.cs +++ b/src/SFA.DAS.AssessorService.Application.Api/Controllers/RegisterQueryController.cs @@ -64,27 +64,6 @@ public async Task GetAssessmentOrganisations() return Ok(await _mediator.Send(new GetAssessmentOrganisationsRequest())); } - [HttpGet("assessment-organisations/apar-summary", Name = "GetAPARSummary")] - [SwaggerResponse((int)HttpStatusCode.OK, Type = typeof(List))] - [SwaggerResponse((int)HttpStatusCode.BadRequest, Type = typeof(IDictionary))] - [SwaggerResponse((int)HttpStatusCode.InternalServerError, Type = typeof(ApiResponse))] - public async Task GetAparSummary() - { - _logger.LogInformation("Get APAR Summary"); - return Ok(await _mediator.Send(new GetAparSummaryRequest())); - } - - [HttpGet("assessment-organisations/apar-summary/{ukprn}", Name = "GetAparSummaryByUkprn")] - [SwaggerResponse((int)HttpStatusCode.OK, Type = typeof(AparSummary))] - [SwaggerResponse((int)HttpStatusCode.BadRequest, Type = typeof(IDictionary))] - [SwaggerResponse((int)HttpStatusCode.InternalServerError, Type = typeof(ApiResponse))] - public async Task GetAparSummaryByUkprn(int ukprn) - { - _logger.LogInformation($"Get Apar Summary by UKPRN [{ukprn}]"); - var results = await _mediator.Send(new GetAparSummaryRequest(ukprn)); - return Ok(results.FirstOrDefault()); - } - [HttpGet("assessment-organisations/{organisationId}", Name = "GetAssessmentOrganisation")] [SwaggerResponse((int) HttpStatusCode.OK, Type = typeof(EpaOrganisation))] [SwaggerResponse((int) HttpStatusCode.NotFound, null)] @@ -239,30 +218,6 @@ public async Task SearchStandards(string searchstring) return Ok(results.Select(s => (StandardVersion)s).ToList()); } - - [HttpPost("assessment-organisations/apar-summary-update", Name = "APARSummaryUpdate")] - [SwaggerResponse((int)HttpStatusCode.Accepted, Type = typeof(int?))] - [SwaggerResponse((int)HttpStatusCode.InternalServerError, Type = typeof(ApiResponse))] - public IActionResult AparSummaryUpdate() - { - var requestName = "update APAR summary"; - return QueueBackgroundRequest(new AparSummaryUpdateRequest(), requestName, (response, duration, log) => - { - var result = response; - log.LogInformation($"Completed request to {requestName}, there were {result} changes made to APAR for EPAOs in {duration.ToReadableString()}"); - }); - } - - [HttpGet("assessment-organisations/apar-summary-last-updated", Name = "GetAparSummaryLastUpdated")] - [SwaggerResponse((int)HttpStatusCode.OK, Type = typeof(List))] - [SwaggerResponse((int)HttpStatusCode.BadRequest, Type = typeof(IDictionary))] - [SwaggerResponse((int)HttpStatusCode.InternalServerError, Type = typeof(ApiResponse))] - public async Task GetAparSummaryLastUpdated() - { - _logger.LogInformation("Getting APAR Summary Last Updated Date"); - - return Ok(await _mediator.Send(new GetAparSummaryLastUpdatedRequest())); - } } } diff --git a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryAparSummaryUpdateTests.cs b/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryAparSummaryUpdateTests.cs deleted file mode 100644 index 38b9bd492f..0000000000 --- a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryAparSummaryUpdateTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Handlers.ao; -using SFA.DAS.AssessorService.Application.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.UnitTests.Handlers.Register.Query -{ - public class RegisterQueryAparSummaryUpdateTests - { - protected Mock _registerQueryRepository; - protected AparSummaryUpdateHandler _aparSummaryUpdateHandler; - protected Mock> _logger; - - [SetUp] - public void Setup() - { - _registerQueryRepository = new Mock(); - - _logger = new Mock>(); - - _registerQueryRepository.Setup(x => x.AparSummaryUpdate()).ReturnsAsync(1); - - _aparSummaryUpdateHandler = new AparSummaryUpdateHandler(_registerQueryRepository.Object, _logger.Object); - } - - [Test] - public void AparSummaryUpdateRepoIsCalledWhenHandlerIsInvoked() - { - _aparSummaryUpdateHandler.Handle(new AparSummaryUpdateRequest(), CancellationToken.None).Wait(); - _registerQueryRepository.Verify(x => x.AparSummaryUpdate()); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryLastUpdatedTests.cs b/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryLastUpdatedTests.cs deleted file mode 100644 index 20679edc00..0000000000 --- a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryLastUpdatedTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Handlers.ao; -using SFA.DAS.AssessorService.Application.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.UnitTests.Handlers.Register.Query -{ - public class RegisterQueryGetAparSummaryLastUpdatedTests - { - protected Mock RegisterQueryRepository; - protected GetAparSummaryLastUpdatedHandler AparSummaryLastUpdatedHandler; - protected Mock> Logger; - - [SetUp] - public void Setup() - { - RegisterQueryRepository = new Mock(); - - Logger = new Mock>(); - - RegisterQueryRepository.Setup(x => x.GetAparSummaryLastUpdated()).ReturnsAsync(DateTime.UtcNow); - - AparSummaryLastUpdatedHandler = new GetAparSummaryLastUpdatedHandler(RegisterQueryRepository.Object, Logger.Object); - } - - [Test] - public void AparSummaryUpdateRepoIsCalledWhenHandlerIsInvoked() - { - AparSummaryLastUpdatedHandler.Handle(new GetAparSummaryLastUpdatedRequest(), CancellationToken.None).Wait(); - RegisterQueryRepository.Verify(x => x.GetAparSummaryLastUpdated()); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryTests.cs b/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryTests.cs deleted file mode 100644 index 9bccd59558..0000000000 --- a/src/SFA.DAS.AssessorService.Application.UnitTests/Handlers/Register/Query/RegisterQueryGetAparSummaryTests.cs +++ /dev/null @@ -1,100 +0,0 @@ -using FluentAssertions; -using Microsoft.Extensions.Logging; -using Moq; -using NUnit.Framework; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Api.Types.Models.AO; -using SFA.DAS.AssessorService.Application.Handlers.ao; -using SFA.DAS.AssessorService.Application.Interfaces; -using System.Collections.Generic; -using System.Linq; -using System.Threading; - -namespace SFA.DAS.AssessorService.Application.UnitTests.Handlers.Register.Query -{ - [TestFixture] - public class RegisterQueryGetAparSummaryTests - { - protected GetAparSummaryHandler _sut; - protected Mock> _logger; - protected Mock _registerQueryRepository; - - private IEnumerable _expectedAparSummary; - private IEnumerable _expectedAparSummaryForUkprn1111111; - private IEnumerable _expectedAparSummaryForUkprn2222222; - private AparSummary _aparSummary1111111; - private AparSummary _aparSummary2222222; - - [SetUp] - public void Setup() - { - _registerQueryRepository = new Mock(); - _aparSummary1111111 = new AparSummary { Id = "EPA0001", Name = "Name 1", Ukprn = 1111111 }; - _aparSummary2222222 = new AparSummary { Id = "EPA0002", Name = "Name 2", Ukprn = 2222222 }; - - _logger = new Mock>(); - - _expectedAparSummary = new List - { - _aparSummary1111111, - _aparSummary2222222 - }; - - _expectedAparSummaryForUkprn1111111 = new List - { - _aparSummary1111111 - }; - - _expectedAparSummaryForUkprn2222222 = new List - { - _aparSummary2222222 - }; - - _registerQueryRepository.Setup(r => r.GetAparSummary(null)) - .ReturnsAsync(_expectedAparSummary); - - _registerQueryRepository.Setup(r => r.GetAparSummary(1111111)) - .ReturnsAsync(_expectedAparSummaryForUkprn1111111); - - _registerQueryRepository.Setup(r => r.GetAparSummary(2222222)) - .ReturnsAsync(_expectedAparSummaryForUkprn2222222); - - _sut = new GetAparSummaryHandler(_registerQueryRepository.Object, _logger.Object); - } - - [TestCase(1111111)] - [TestCase(2222222)] - public void Handle_ReturnExpectedListAparSummaryForSpecificUkprn_WhenHandlerIsInvoked(int ukprn) - { - var organisations = _sut.Handle(new GetAparSummaryRequest(ukprn), new CancellationToken()).Result; - - organisations.Should().HaveCount(1, "because there should be exactly one apar summary with a matching ukprn"); - organisations.Single().Ukprn.Should().Be(ukprn); - } - - [TestCase(1111111)] - [TestCase(2222222)] - public void Handle_GetAparSummaryByUkprnRequestIsCalledForSpecificUkprn_WhenHandlerIsInvoked(int ukprn) - { - _sut.Handle(new GetAparSummaryRequest(ukprn), new CancellationToken()).Wait(); - _registerQueryRepository.Verify(r => r.GetAparSummary(ukprn)); - } - - [Test] - public void Handle_ReturnExpectedListAparSummaryForNonSpecificUkprn_WhenHandlerIsInvoked() - { - var organisations = _sut.Handle(new GetAparSummaryRequest(), new CancellationToken()).Result; - - organisations.Should().HaveCount(2, "because there should be exactly two apar summaries with any matching ukprn"); - organisations.First().Ukprn.Should().Be(1111111); - organisations.Last().Ukprn.Should().Be(2222222); - } - - [Test] - public void Handle_GetAparSummaryByUkprnRequestIsCalledForNonSpecificUkprn_WhenHandlerIsInvoked() - { - _sut.Handle(new GetAparSummaryRequest(), new CancellationToken()).Wait(); - _registerQueryRepository.Verify(r => r.GetAparSummary(null)); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application/Handlers/ao/AparSummaryUpdateHandler.cs b/src/SFA.DAS.AssessorService.Application/Handlers/ao/AparSummaryUpdateHandler.cs deleted file mode 100644 index 7638a19bc9..0000000000 --- a/src/SFA.DAS.AssessorService.Application/Handlers/ao/AparSummaryUpdateHandler.cs +++ /dev/null @@ -1,28 +0,0 @@ -using MediatR; -using Microsoft.Extensions.Logging; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Interfaces; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.Handlers.ao -{ - public class AparSummaryUpdateHandler : IRequestHandler - { - private readonly IRegisterQueryRepository _registerQueryRepository; - private readonly ILogger _logger; - - public AparSummaryUpdateHandler(IRegisterQueryRepository registerQueryRepository, ILogger logger) - { - _registerQueryRepository = registerQueryRepository; - _logger = logger; - } - - public async Task Handle(AparSummaryUpdateRequest request, CancellationToken cancellationToken) - { - _logger.LogInformation("Handling AparSummaryUpdateRequest"); - - return await _registerQueryRepository.AparSummaryUpdate(); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryHandler.cs b/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryHandler.cs deleted file mode 100644 index a23fe78109..0000000000 --- a/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryHandler.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediatR; -using Microsoft.Extensions.Logging; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Api.Types.Models.AO; -using SFA.DAS.AssessorService.Application.Interfaces; - -namespace SFA.DAS.AssessorService.Application.Handlers.ao -{ - public class GetAparSummaryHandler : IRequestHandler> - { - private readonly IRegisterQueryRepository _registerQueryRepository; - private readonly ILogger _logger; - - public GetAparSummaryHandler(IRegisterQueryRepository registerQueryRepository, ILogger logger) - { - _registerQueryRepository = registerQueryRepository; - _logger = logger; - } - - public async Task> Handle(GetAparSummaryRequest request, CancellationToken cancellationToken) - { - _logger.LogInformation("Handling GetAparSummaryByUkprnRequest"); - var result = await _registerQueryRepository.GetAparSummary(request.Ukprn); - return result.ToList(); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryLastUpdatedHandler.cs b/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryLastUpdatedHandler.cs deleted file mode 100644 index d68a9e0bb6..0000000000 --- a/src/SFA.DAS.AssessorService.Application/Handlers/ao/GetAparSummaryLastUpdatedHandler.cs +++ /dev/null @@ -1,29 +0,0 @@ -using MediatR; -using Microsoft.Extensions.Logging; -using SFA.DAS.AssessorService.Api.Types.Models; -using SFA.DAS.AssessorService.Application.Interfaces; -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Application.Handlers.ao -{ - public class GetAparSummaryLastUpdatedHandler : IRequestHandler - { - private readonly IRegisterQueryRepository _registerQueryRepository; - private readonly ILogger _logger; - - public GetAparSummaryLastUpdatedHandler(IRegisterQueryRepository registerQueryRepository, ILogger logger) - { - _registerQueryRepository = registerQueryRepository; - _logger = logger; - } - - public async Task Handle(GetAparSummaryLastUpdatedRequest request, CancellationToken cancellationToken) - { - _logger.LogInformation("Handling GetAparSummaryLastUpdatedRequest request"); - - return await _registerQueryRepository.GetAparSummaryLastUpdated(); - } - } -} diff --git a/src/SFA.DAS.AssessorService.Application/Interfaces/IRegisterQueryRepository.cs b/src/SFA.DAS.AssessorService.Application/Interfaces/IRegisterQueryRepository.cs index 7ab57779ba..5daa41048f 100644 --- a/src/SFA.DAS.AssessorService.Application/Interfaces/IRegisterQueryRepository.cs +++ b/src/SFA.DAS.AssessorService.Application/Interfaces/IRegisterQueryRepository.cs @@ -28,7 +28,6 @@ public interface IRegisterQueryRepository Task> GetAssessmentOrganisationsByNameOrCharityNumberOrCompanyNumber(string organisationName); Task> GetAllOrganisationStandardByOrganisationId(string organisationId); Task GetOrganisationStandardFromOrganisationStandardId(int organisationStandardId); - Task> GetAparSummary(int? ukprn = null); Task> GetAppliedStandardVersionsForEPAO(string organisationId, string standardReference); @@ -38,8 +37,5 @@ public interface IRegisterQueryRepository Task> GetDeliveryAreasByOrganisationStandardId(int organisationStandardId); Task GetEpaOrgIdByEndPointAssessmentName(string name); - - Task AparSummaryUpdate(); - Task GetAparSummaryLastUpdated(); } } diff --git a/src/SFA.DAS.AssessorService.Data.IntegrationTests/Repositories/RegisterQueryRepositoryTests/GetAparSummaryTests.cs b/src/SFA.DAS.AssessorService.Data.IntegrationTests/Repositories/RegisterQueryRepositoryTests/GetAparSummaryTests.cs deleted file mode 100644 index 96c74f6fa7..0000000000 --- a/src/SFA.DAS.AssessorService.Data.IntegrationTests/Repositories/RegisterQueryRepositoryTests/GetAparSummaryTests.cs +++ /dev/null @@ -1,597 +0,0 @@ -using FluentAssertions; -using FluentAssertions.Execution; -using Microsoft.VisualStudio.TestPlatform.ObjectModel; -using NUnit.Framework; -using SFA.DAS.AssessorService.Api.Types.Models.AO; -using SFA.DAS.AssessorService.Data.IntegrationTests.Services; -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.Linq; -using System.Threading.Tasks; - -namespace SFA.DAS.AssessorService.Data.IntegrationTests.Repositories.RegisterQueryRepositoryTests -{ - public class GetAparSummaryTests : TestBase - { - private static DateTime DefaultEffectiveFrom = DateTime.Today.AddDays(-50); - private static DateTime DefaultDateStandardApprovedOnRegister = DateTime.Today.AddDays(-45); - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenOrganisationHasAtLeastOneStandardVersion() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesOrganisations_WhenOrganisationDoesNotHaveAtLeastOneStandardVersion() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister)) // no standard version - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001") - .VerifyResultsNotContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenOrganisationStandardEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenOrganisationStandardEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, DateTime.Now.AddDays(1), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, DateTime.Now.AddDays(1), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesOrganisations_WhenOrganisationStandardEffectiveToInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, DateTime.Now.AddDays(1), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, DateTime.Now.AddDays(-1), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001") - .VerifyResultsNotContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenOrganisationStandardVersionEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenOrganisationStandardVersionEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, DateTime.Now.AddDays(1)) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, DateTime.Now.AddDays(1))) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesOrganisations_WhenOrganisationStandardVersionEffectiveToInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, DateTime.Now.AddDays(-1))) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001") - .VerifyResultsNotContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenStandardEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard1", "ST0001", 101, "1.1", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.1", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesOrganisations_WhenStandardEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard1", "ST0001", 101, "1.1", DefaultEffectiveFrom, DateTime.Today.AddDays(1)) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.1", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(2) - .VerifyResultsContain("EPA0001") - .VerifyResultsContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesOrganisations_WhenStandardEffectiveToDateInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard1", "ST0001", 101, "1.1", DefaultEffectiveFrom, DateTime.Today.AddDays(-1)) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.1", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001") - .VerifyResultsNotContain("EPA0002"); - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenOrganisationStandardHasAtLeastOneStandardVersion() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesStandards_WhenOrganisationDoesNotHaveAtLeastOneStandardVersion() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) // no standard version - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom.AddDays(5), DefaultDateStandardApprovedOnRegister.AddDays(5)); // the later standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenOrganisationStandardVersionHasEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenOrganisationStandardVersionHasEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, DateTime.Today.AddDays(10)) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesStandards_WhenOrganisationStandardVersionHasEffectiveToDateInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, DateTime.Today.AddDays(-10)) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom.AddDays(5), DefaultDateStandardApprovedOnRegister.AddDays(5)); // the later standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenOrganisationStandardHasEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenOrganisationStandardHasEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, DateTime.Today.AddDays(10), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesStandards_WhenOrganisationStandardHasEffectiveToDateInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, DateTime.Today.AddDays(-10), DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom.AddDays(5), DefaultDateStandardApprovedOnRegister.AddDays(5)); // the later standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenStandardHasEffectiveToDateNotSet() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_IncludesStandards_WhenStandardHasEffectiveToDateInFuture() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, DateTime.Today.AddDays(10)) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom, DefaultDateStandardApprovedOnRegister); // the earlier standard is chosen - } - } - } - - [Test] - public async Task GetAparSummary_ExcludesStandards_WhenStandardHasEffectiveToDateInPast() - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, DateTime.Today.AddDays(-10)) - .WithStandard("TestStandard2", "ST0002", 102, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisationStandard(2, "EPA0001", 102, "ST0002", DefaultEffectiveFrom.AddDays(5), null, DefaultDateStandardApprovedOnRegister.AddDays(5)) - .WithOrganisationStandardVersion("EPA0001", 102, "ST0002", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain("EPA0001", DefaultEffectiveFrom.AddDays(5), DefaultDateStandardApprovedOnRegister.AddDays(5)); // the later standard is chosen - } - } - } - - [TestCase(123456, "EPA0001")] - [TestCase(123456, "EPA0001")] - [TestCase(123456, "EPA0001")] - public async Task GetAparSummary_IncludesOrganisationForSpecificUkprn_WhenOrganisationHasAtLeastOneStandardVersion(int ukprn, string expectedEndPointAssessorOrganisationId) - { - using (var fixture = new GetAparSummaryTestsFixture() - .WithStandard("TestStandard1", "ST0001", 101, "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation1", "EPA0001", 123456, null) - .WithOrganisationStandard(1, "EPA0001", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0001", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation2", "EPA0002", 612345, null) - .WithOrganisationStandard(2, "EPA0002", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0002", 101, "ST0001", "1.0", DefaultEffectiveFrom, null) - .WithOrganisation("Organisation3", "EPA0003", 561234, null) - .WithOrganisationStandard(3, "EPA0003", 101, "ST0001", DefaultEffectiveFrom, null, DefaultDateStandardApprovedOnRegister) - .WithOrganisationStandardVersion("EPA0003", 101, "ST0001", "1.0", DefaultEffectiveFrom, null)) - { - var result = await fixture.GetAparSummary(ukprn); - - using (new AssertionScope()) - { - result.VerifyNumberOfResults(1) - .VerifyResultsContain(expectedEndPointAssessorOrganisationId); - } - } - } - - private class GetAparSummaryTestsFixture : FixtureBase, IDisposable - { - private readonly DatabaseService _databaseService = new DatabaseService(); - private readonly SqlConnection _sqlConnection; - - private RegisterQueryRepository _repository; - public IEnumerable _results; - - public GetAparSummaryTestsFixture() - { - _sqlConnection = new SqlConnection(_databaseService.SqlConnectionStringTest); - _repository = new RegisterQueryRepository(new UnitOfWork(_sqlConnection)); - } - - public async Task GetAparSummary() - { - await _repository.AparSummaryUpdate(); - _results = await _repository.GetAparSummary(); - return this; - } - - public async Task GetAparSummary(int ukprn) - { - await _repository.AparSummaryUpdate(); - _results = await _repository.GetAparSummary(ukprn); - return this; - } - - public GetAparSummaryTestsFixture VerifyNumberOfResults(int numberOfResults) - { - _results.Count().Should().Be(numberOfResults); - return this; - } - - public GetAparSummaryTestsFixture VerifyResultsNotContain(string endPointAssessorOrganisationId) - { - _results.Should().NotContain(o => o.Id == endPointAssessorOrganisationId); - return this; - } - - public GetAparSummaryTestsFixture VerifyResultsContain(string endPointAssessorOrganisationId) - { - _results.Should().Contain(o => o.Id == endPointAssessorOrganisationId); - return this; - } - - public GetAparSummaryTestsFixture VerifyResultsContain(string endPointAssessorOrganisationId, DateTime? earlistStandardEffectiveFromDate, DateTime? earliestDateStandardApprovedOnRegister) - { - _results.Should().Contain(o => o.Id == endPointAssessorOrganisationId - && o.EarliestEffectiveFromDate == earlistStandardEffectiveFromDate - && o.EarliestDateStandardApprovedOnRegister == earliestDateStandardApprovedOnRegister); - return this; - } - } - } -} \ No newline at end of file diff --git a/src/SFA.DAS.AssessorService.Data/RegisterQueryRepository.cs b/src/SFA.DAS.AssessorService.Data/RegisterQueryRepository.cs index 7756a2f950..3fb32da6b1 100644 --- a/src/SFA.DAS.AssessorService.Data/RegisterQueryRepository.cs +++ b/src/SFA.DAS.AssessorService.Data/RegisterQueryRepository.cs @@ -102,26 +102,6 @@ await _unitOfWork.Connection.QueryAsync( return assessmentOrganisationSummaries; } - public async Task> GetAparSummary(int? ukprn = null) - { - var sql = - "SELECT " + - "a.EndPointAssessorOrganisationId as Id, " + - "a.EndPointAssessorName as Name, " + - "a.EndPointAssessorUkprn as Ukprn, " + - "a.EarliestDateStandardApprovedOnRegister, " + - "a.EarliestEffectiveFromDate " + - "FROM [dbo].[APARSummary] a "; - - if (ukprn != null) - { - sql += "WHERE a.EndPointAssessorUkprn = @ukprn"; - } - - return await _unitOfWork.Connection.QueryAsync(sql, new { ukprn }); - } - - public async Task> GetAssessmentOrganisationContacts(string organisationId) { var sql = @@ -434,25 +414,5 @@ public async Task GetEpaOrgIdByEndPointAssessmentName(string name) return await _unitOfWork.Connection.QueryFirstOrDefaultAsync(sql, new { name }); } - - public async Task AparSummaryUpdate() - { - var result = await _unitOfWork.Connection.QueryAsync( - "AparSummaryUpdate", - transaction: _unitOfWork.Transaction, - commandType: CommandType.StoredProcedure); - - return result.First(); - } - - public async Task GetAparSummaryLastUpdated() - { - var sql = - "SELECT " + - "a.LastUpdated " + - "FROM [dbo].[APARSummaryUpdated] a"; - - return await _unitOfWork.Connection.QueryFirstOrDefaultAsync(sql); - } } } \ No newline at end of file diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/CON-3359_Remove_IlrsImport.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/CON-3359_Remove_IlrsImport.sql deleted file mode 100644 index a27bb0e488..0000000000 --- a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/CON-3359_Remove_IlrsImport.sql +++ /dev/null @@ -1,4 +0,0 @@ -/* - Remove the redundant table IlrsImport -*/ -DROP TABLE IF EXISTS dbo.IlrsImport \ No newline at end of file diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1366-MapOFQUALRNtoEPAOrgId.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1366-MapOFQUALRNtoEPAOrgId.sql deleted file mode 100644 index 00ba002d4d..0000000000 --- a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1366-MapOFQUALRNtoEPAOrgId.sql +++ /dev/null @@ -1,143 +0,0 @@ --- assign RN number to existing EPAOs. --- -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5112' WHERE EndPointAssessorOrganisationId = 'EPA0091' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5113' WHERE EndPointAssessorOrganisationId = 'EPA0038' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5117' WHERE EndPointAssessorOrganisationId = 'EPA0002' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5118' WHERE EndPointAssessorOrganisationId = 'EPA0039' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5127' WHERE EndPointAssessorOrganisationId = 'EPA0240' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5128' WHERE EndPointAssessorOrganisationId = 'EPA0026' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5133' WHERE EndPointAssessorOrganisationId = 'EPA0016' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5135' WHERE EndPointAssessorOrganisationId = 'EPA0221' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5136' WHERE EndPointAssessorOrganisationId = 'EPA0057' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5137' WHERE EndPointAssessorOrganisationId = 'EPA0179' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5142' WHERE EndPointAssessorOrganisationId = 'EPA0007' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5148' WHERE EndPointAssessorOrganisationId = 'EPA0899' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5152' WHERE EndPointAssessorOrganisationId = 'EPA0073' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5156' WHERE EndPointAssessorOrganisationId = 'EPA0033' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5157' WHERE EndPointAssessorOrganisationId = 'EPA0013' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5162' WHERE EndPointAssessorOrganisationId = 'EPA0142' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5167' WHERE EndPointAssessorOrganisationId = 'EPA0052' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5181' WHERE EndPointAssessorOrganisationId = 'EPA0006' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5184' WHERE EndPointAssessorOrganisationId = 'EPA0011' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5188' WHERE EndPointAssessorOrganisationId = 'EPA0001' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5194' WHERE EndPointAssessorOrganisationId = 'EPA0014' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5195' WHERE EndPointAssessorOrganisationId = 'EPA0125' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5197' WHERE EndPointAssessorOrganisationId = 'EPA0685' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5198' WHERE EndPointAssessorOrganisationId = 'EPA0069' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5202' WHERE EndPointAssessorOrganisationId = 'EPA0191' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5204' WHERE EndPointAssessorOrganisationId = 'EPA0022' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5213' WHERE EndPointAssessorOrganisationId = 'EPA0018' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5216' WHERE EndPointAssessorOrganisationId = 'EPA0175' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5217' WHERE EndPointAssessorOrganisationId = 'EPA0008' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5219' WHERE EndPointAssessorOrganisationId = 'EPA0042' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5220' WHERE EndPointAssessorOrganisationId = 'EPA0031' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5223' WHERE EndPointAssessorOrganisationId = 'EPA0093' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5224' WHERE EndPointAssessorOrganisationId = 'EPA0130' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5226' WHERE EndPointAssessorOrganisationId = 'EPA0110' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5227' WHERE EndPointAssessorOrganisationId = 'EPA0025' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5229' WHERE EndPointAssessorOrganisationId = 'EPA0479' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5239' WHERE EndPointAssessorOrganisationId = 'EPA0053' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5252' WHERE EndPointAssessorOrganisationId = 'EPA0098' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5256' WHERE EndPointAssessorOrganisationId = 'EPA0090' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5260' WHERE EndPointAssessorOrganisationId = 'EPA0010' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5264' WHERE EndPointAssessorOrganisationId = 'EPA0005' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5289' WHERE EndPointAssessorOrganisationId = 'EPA0565' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5291' WHERE EndPointAssessorOrganisationId = 'EPA0490' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5322' WHERE EndPointAssessorOrganisationId = 'EPA0064' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5325' WHERE EndPointAssessorOrganisationId = 'EPA0058' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5336' WHERE EndPointAssessorOrganisationId = 'EPA0267' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5351' WHERE EndPointAssessorOrganisationId = 'EPA0082' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5355' WHERE EndPointAssessorOrganisationId = 'EPA0061' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5359' WHERE EndPointAssessorOrganisationId = 'EPA0340' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5360' WHERE EndPointAssessorOrganisationId = 'EPA0045' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN5361' WHERE EndPointAssessorOrganisationId = 'EPA0023' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6006' WHERE EndPointAssessorOrganisationId = 'EPA0041' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6010' WHERE EndPointAssessorOrganisationId = 'EPA0241' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6012' WHERE EndPointAssessorOrganisationId = 'EPA0234' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6013' WHERE EndPointAssessorOrganisationId = 'EPA0264' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6022' WHERE EndPointAssessorOrganisationId = 'EPA0775' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6024' WHERE EndPointAssessorOrganisationId = 'EPA0154' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6025' WHERE EndPointAssessorOrganisationId = 'EPA0314' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6026' WHERE EndPointAssessorOrganisationId = 'EPA0501' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6028' WHERE EndPointAssessorOrganisationId = 'EPA0009' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6029' WHERE EndPointAssessorOrganisationId = 'EPA0047' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6030' WHERE EndPointAssessorOrganisationId = 'EPA0048' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6031' WHERE EndPointAssessorOrganisationId = 'EPA0077' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6033' WHERE EndPointAssessorOrganisationId = 'EPA0084' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6036' WHERE EndPointAssessorOrganisationId = 'EPA0843' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6038' WHERE EndPointAssessorOrganisationId = 'EPA0170' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6039' WHERE EndPointAssessorOrganisationId = 'EPA0055' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6041' WHERE EndPointAssessorOrganisationId = 'EPA0711' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6042' WHERE EndPointAssessorOrganisationId = 'EPA0198' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6043' WHERE EndPointAssessorOrganisationId = 'EPA0440' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6044' WHERE EndPointAssessorOrganisationId = 'EPA0608' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6045' WHERE EndPointAssessorOrganisationId = 'EPA0458' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6046' WHERE EndPointAssessorOrganisationId = 'EPA0163' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6048' WHERE EndPointAssessorOrganisationId = 'EPA0095' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6051' WHERE EndPointAssessorOrganisationId = 'EPA0188' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6052' WHERE EndPointAssessorOrganisationId = 'EPA0196' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6054' WHERE EndPointAssessorOrganisationId = 'EPA0568' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6055' WHERE EndPointAssessorOrganisationId = 'EPA0303' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6056' WHERE EndPointAssessorOrganisationId = 'EPA0447' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6057' WHERE EndPointAssessorOrganisationId = 'EPA0269' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6059' WHERE EndPointAssessorOrganisationId = 'EPA0133' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6060' WHERE EndPointAssessorOrganisationId = 'EPA0050' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6061' WHERE EndPointAssessorOrganisationId = 'EPA0227' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6063' WHERE EndPointAssessorOrganisationId = 'EPA0202' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6065' WHERE EndPointAssessorOrganisationId = 'EPA0028' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6066' WHERE EndPointAssessorOrganisationId = 'EPA0178' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6067' WHERE EndPointAssessorOrganisationId = 'EPA0593' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6068' WHERE EndPointAssessorOrganisationId = 'EPA0097' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6069' WHERE EndPointAssessorOrganisationId = 'EPA0400' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6070' WHERE EndPointAssessorOrganisationId = 'EPA0060' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6071' WHERE EndPointAssessorOrganisationId = 'EPA0225' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6072' WHERE EndPointAssessorOrganisationId = 'EPA0181' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6073' WHERE EndPointAssessorOrganisationId = 'EPA0214' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6074' WHERE EndPointAssessorOrganisationId = 'EPA0232' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6075' WHERE EndPointAssessorOrganisationId = 'EPA0452' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6076' WHERE EndPointAssessorOrganisationId = 'EPA0395' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6077' WHERE EndPointAssessorOrganisationId = 'EPA0118' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6078' WHERE EndPointAssessorOrganisationId = 'EPA0212' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6080' WHERE EndPointAssessorOrganisationId = 'EPA0742' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6081' WHERE EndPointAssessorOrganisationId = 'EPA0461' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6082' WHERE EndPointAssessorOrganisationId = 'EPA0208' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6083' WHERE EndPointAssessorOrganisationId = 'EPA0284' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6085' WHERE EndPointAssessorOrganisationId = 'EPA0051' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6086' WHERE EndPointAssessorOrganisationId = 'EPA0935' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6087' WHERE EndPointAssessorOrganisationId = 'EPA0072' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6088' WHERE EndPointAssessorOrganisationId = 'EPA0109' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6089' WHERE EndPointAssessorOrganisationId = 'EPA0387' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6091' WHERE EndPointAssessorOrganisationId = 'EPA0252' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6092' WHERE EndPointAssessorOrganisationId = 'EPA0475' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6093' WHERE EndPointAssessorOrganisationId = 'EPA0218' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6095' WHERE EndPointAssessorOrganisationId = 'EPA0140' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6096' WHERE EndPointAssessorOrganisationId = 'EPA0889' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6098' WHERE EndPointAssessorOrganisationId = 'EPA0265' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6099' WHERE EndPointAssessorOrganisationId = 'EPA0279' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6100' WHERE EndPointAssessorOrganisationId = 'EPA0548' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6101' WHERE EndPointAssessorOrganisationId = 'EPA0062' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6102' WHERE EndPointAssessorOrganisationId = 'EPA0331' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6103' WHERE EndPointAssessorOrganisationId = 'EPA0199' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6104' WHERE EndPointAssessorOrganisationId = 'EPA0157' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6107' WHERE EndPointAssessorOrganisationId = 'EPA0530' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6111' WHERE EndPointAssessorOrganisationId = 'EPA0547' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6114' WHERE EndPointAssessorOrganisationId = 'EPA0338' AND [RecognitionNumber] IS NULL; --- Additions 19/06/23 -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6032' WHERE EndPointAssessorOrganisationId = 'EPA0497' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6049' WHERE EndPointAssessorOrganisationId = 'EPA0085' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6062' WHERE EndPointAssessorOrganisationId = 'EPA0224' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6116' WHERE EndPointAssessorOrganisationId = 'EPA0204' AND [RecognitionNumber] IS NULL; --- Additions 14/07/23 -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6113' WHERE EndPointAssessorOrganisationId = 'EPA0211' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6090' WHERE EndPointAssessorOrganisationId = 'EPA0246' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6118' WHERE EndPointAssessorOrganisationId = 'EPA0514' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6119' WHERE EndPointAssessorOrganisationId = 'EPA0229' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6117' WHERE EndPointAssessorOrganisationId = 'EPA0826' AND [RecognitionNumber] IS NULL; -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6112' WHERE EndPointAssessorOrganisationId = 'EPA0715' AND [RecognitionNumber] IS NULL; --- Additions 18/07/23 -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6064' WHERE EndPointAssessorOrganisationId = 'EPA0235' AND [RecognitionNumber] IS NULL; --- Additions 24/07/23 -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6058' WHERE EndPointAssessorOrganisationId = 'EPA0369' AND [RecognitionNumber] IS NULL; --- Additions 26/07/23 -UPDATE [dbo].[organisations] SET [RecognitionNumber] ='RN6109' WHERE EndPointAssessorOrganisationId = 'EPA1003' AND [RecognitionNumber] IS NULL; - diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1912-UpdatePendingUsersToLive.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1912-UpdatePendingUsersToLive.sql deleted file mode 100644 index 2b7fe03b8c..0000000000 --- a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/QF-1912-UpdatePendingUsersToLive.sql +++ /dev/null @@ -1,13 +0,0 @@ -/* - Temporary script to update the Status for Pending users with a non-null GovUkIdentifier to Live. - Only needs to be run once on each environment. -*/ - -UPDATE dbo.Contacts -SET - [Status] = 'Live' -WHERE - [Status] = 'Pending' - AND [GovUkIdentifier] IS NOT NULL - AND [GovUkIdentifier] != ''; - diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/SV-1290-RemoveOldStandardCollationTables.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/SV-1290-RemoveOldStandardCollationTables.sql deleted file mode 100644 index 18f36b5c3e..0000000000 --- a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/SV-1290-RemoveOldStandardCollationTables.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Remove old Standard Collation Tables -*/ - -IF EXISTS (SELECT TOP(1) * FROM sys.tables WHERE NAME = 'Options') DROP TABLE Options -IF EXISTS (SELECT TOP(1) * FROM sys.tables WHERE NAME = 'StandardCollation') DROP TABLE StandardCollation -IF EXISTS (SELECT TOP(1) * FROM sys.tables WHERE NAME = 'StandardNonApprovedCollation') DROP TABLE StandardNonApprovedCollation - diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/ON-613_Patch_standard_reference.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/ON-613_Patch_standard_reference.sql new file mode 100644 index 0000000000..59c71e499c --- /dev/null +++ b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/ON-613_Patch_standard_reference.sql @@ -0,0 +1,18 @@ +-- ON-613 Patch Certificates with STxxxx StandardReference, where it is not yet included. +-- AB 11/03/19 Keep this active for new deployments, for now +-- AB 31/07/19 Still seeing existance of certs without Standard reference (need to understand why) +-- **************************************************************************** +-- AB 10/05/21 Keeping this for now to patch FAILs recorded via the API +; +WITH Standards_CTE AS( +SELECT ROW_NUMBER() OVER (PARTITION BY Ifatereferencenumber ORDER BY VersionMajor DESC, VersionMinor DESC) seq, * FROM Standards WHERE LarsCode != 0) + +MERGE INTO certificates ma1 +USING ( +SELECT ce1.[Id],JSON_MODIFY([CertificateData],'$.StandardReference', st1.IFateReferenceNumber) newData + FROM [Certificates] ce1 + JOIN Standards_CTE st1 ON ce1.StandardCode = st1.LarsCode and st1.seq = 1 + WHERE st1.IFateReferenceNumber IS NOT NULL + AND JSON_VALUE([CertificateData],'$.StandardReference') IS NULL) up1 +ON (ma1.id = up1.id) +WHEN MATCHED THEN UPDATE SET ma1.[CertificateData] = up1.[newData]; \ No newline at end of file diff --git a/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/P2-2241_Drop_apar_tables.sql b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/P2-2241_Drop_apar_tables.sql new file mode 100644 index 0000000000..09c788c9ff --- /dev/null +++ b/src/SFA.DAS.AssessorService.Database/PostDeploymentScripts/TemporaryPatches/P2-2241_Drop_apar_tables.sql @@ -0,0 +1,8 @@ +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[APARSummary]') AND type in (N'U')) +DROP TABLE [dbo].[APARSummary] +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[APARSummaryUpdated]') AND type in (N'U')) +DROP TABLE [dbo].[APARSummaryUpdated] +GO + diff --git a/src/SFA.DAS.AssessorService.Database/SFA.DAS.AssessorService.Database.sqlproj b/src/SFA.DAS.AssessorService.Database/SFA.DAS.AssessorService.Database.sqlproj index 3c0d7fa2d1..ecc3c5beb0 100644 --- a/src/SFA.DAS.AssessorService.Database/SFA.DAS.AssessorService.Database.sqlproj +++ b/src/SFA.DAS.AssessorService.Database/SFA.DAS.AssessorService.Database.sqlproj @@ -73,6 +73,7 @@ + @@ -157,7 +158,6 @@ - @@ -175,8 +175,6 @@ - - @@ -188,16 +186,13 @@ - - - - + @@ -221,7 +216,7 @@ - + diff --git a/src/SFA.DAS.AssessorService.Database/Script.PostDeployment1.sql b/src/SFA.DAS.AssessorService.Database/Script.PostDeployment1.sql index 57f9cb9325..4d24580cdd 100644 --- a/src/SFA.DAS.AssessorService.Database/Script.PostDeployment1.sql +++ b/src/SFA.DAS.AssessorService.Database/Script.PostDeployment1.sql @@ -17,41 +17,11 @@ /* START OF TEMPORARY SCRIPT SECTION - Each temporary script should be stored under the 'PostDeploymentScripts' folder prefixed with the Jira ticket number + Each temporary script should be stored under the 'PostDeploymentScripts\TemporaryPatches' folder prefixed with the Jira ticket number for which it has been created and will be run on each deployment, so all scripts should be written as IDEMPOTENT. - When a script has been deployed to ALL environments it can be disabled by removing the reference below and optionally retained - under the PostDeploymentScripts folder for future reference. + When a script has been deployed to ALL environments it can be removed. */ --- CON-3359 -:r .\PostDeploymentScripts\CON-3359_Remove_IlrsImport.sql - --- ON-613 Patch Certificates with STxxxx StandardReference, where it is not yet included. --- AB 11/03/19 Keep this active for new deployments, for now --- AB 31/07/19 Still seeing existance of certs without Standard reference (need to understand why) --- **************************************************************************** --- AB 10/05/21 Keeping this for now to patch FAILs recorded via the API -; -WITH Standards_CTE AS( -SELECT ROW_NUMBER() OVER (PARTITION BY Ifatereferencenumber ORDER BY VersionMajor DESC, VersionMinor DESC) seq, * FROM Standards WHERE LarsCode != 0) - -MERGE INTO certificates ma1 -USING ( -SELECT ce1.[Id],JSON_MODIFY([CertificateData],'$.StandardReference', st1.IFateReferenceNumber) newData - FROM [Certificates] ce1 - JOIN Standards_CTE st1 ON ce1.StandardCode = st1.LarsCode and st1.seq = 1 - WHERE st1.IFateReferenceNumber IS NOT NULL - AND JSON_VALUE([CertificateData],'$.StandardReference') IS NULL) up1 -ON (ma1.id = up1.id) -WHEN MATCHED THEN UPDATE SET ma1.[CertificateData] = up1.[newData]; - ---SV-1290 Remove Un-necessary tbles -:r .\PostDeploymentScripts\SV-1290-RemoveOldStandardCollationTables.sql - ---QF-1366 Map OFQUAL RN to EPAOrgId -:r .\PostDeploymentScripts\QF-1366-MapOFQUALRNtoEPAOrgId.sql - ---QF-1912 Update Pending users to Live. ---Temporary script which can be removed from Post Deployment once it has been run on all environments -:r .\PostDeploymentScripts\QF-1912-UpdatePendingUsersToLive.sql +:r .\PostDeploymentScripts\TemporaryPatches\ON-613_Patch_standard_reference.sql +:r .\PostDeploymentScripts\TemporaryPatches\P2-2241_Drop_apar_tables.sql diff --git a/src/SFA.DAS.AssessorService.Database/StoredProcedures/AparSummaryUpdate.sql b/src/SFA.DAS.AssessorService.Database/StoredProcedures/AparSummaryUpdate.sql deleted file mode 100644 index bd62aa8b99..0000000000 --- a/src/SFA.DAS.AssessorService.Database/StoredProcedures/AparSummaryUpdate.sql +++ /dev/null @@ -1,75 +0,0 @@ -CREATE PROCEDURE [dbo].[AparSummaryUpdate] -AS -BEGIN - DECLARE - @updated int = 0; - - WITH APARdata - AS ( - SELECT - os.EndPointAssessorOrganisationId, EndPointAssessorName, EndPointAssessorUkprn, - MIN(os.DateStandardApprovedOnRegister) EarliestDateStandardApprovedOnRegister, - MIN(os.EffectiveFrom) EarliestEffectiveFromDate - FROM - OrganisationStandard os - INNER JOIN - ( - SELECT OrganisationStandardId, StandardUId - FROM OrganisationStandardVersion - WHERE (EffectiveTo IS NULL OR EffectiveTo > GETDATE()) - AND [Status] = 'Live' - ) [ActiveStandardVersions] ON [ActiveStandardVersions].OrganisationStandardId = os.Id - INNER JOIN Organisations o ON os.EndPointAssessorOrganisationId = o.EndPointAssessorOrganisationId - INNER JOIN - ( - SELECT StandardUId - FROM Standards - WHERE LarsCode != 0 - AND (EffectiveTo IS NULL OR EffectiveTo > GETDATE()) - ) [ActiveStandards] ON [ActiveStandards].StandardUid = [ActiveStandardVersions].StandardUId - WHERE - o.[Status] = 'Live' - AND o.EndPointAssessorOrganisationId <> 'EPA0000' - AND (os.EffectiveTo IS NULL OR os.EffectiveTo > GETDATE()) - AND os.[Status] = 'Live' - AND o.[EndPointAssessorUkprn] IS NOT NULL - AND o.[EndPointAssessorUkprn] < 90000000 - GROUP BY - os.EndPointAssessorOrganisationId, EndPointAssessorName, EndPointAssessorUkprn - ) - -- Update, Add or Remove EPAOs - MERGE INTO [dbo].[APARSummary] apar - USING APARdata ad1 - ON (apar.EndPointAssessorOrganisationId = ad1.EndPointAssessorOrganisationId) - WHEN MATCHED AND ( - apar.[EndPointAssessorName] != ad1.[EndPointAssessorName] OR - apar.[EndPointAssessorUkprn] != ad1.[EndPointAssessorUkprn] OR - apar.[EarliestDateStandardApprovedOnRegister] != ad1.[EarliestDateStandardApprovedOnRegister] OR - apar.[EarliestEffectiveFromDate] != ad1.[EarliestEffectiveFromDate] ) - THEN - UPDATE SET - apar.[EndPointAssessorName] = ad1.[EndPointAssessorName], - apar.[EndPointAssessorUkprn] = ad1.[EndPointAssessorUkprn], - apar.[EarliestDateStandardApprovedOnRegister] = ad1.[EarliestDateStandardApprovedOnRegister], - apar.[EarliestEffectiveFromDate] = ad1.[EarliestEffectiveFromDate] - WHEN NOT MATCHED BY TARGET THEN - INSERT VALUES (ad1.[EndPointAssessorOrganisationId],ad1.[EndPointAssessorName],ad1.[EndPointAssessorUkprn],ad1.[EarliestDateStandardApprovedOnRegister],ad1.[EarliestEffectiveFromDate]) - WHEN NOT MATCHED BY SOURCE THEN - DELETE; - - -- return the number of rows changed by Merge - SET @updated = @@ROWCOUNT; - - IF @updated > 0 - BEGIN - -- record the date&time of the latest changes - UPDATE [dbo].[APARSummaryUpdated] SET [LastUpdated] = GETUTCDATE(); - IF @@ROWCOUNT = 0 - INSERT INTO [dbo].[APARSummaryUpdated] ([LastUpdated]) VALUES ( GETUTCDATE() ); - END - - -- return the number of changes made to APAR for EPAOs - SELECT @updated - -END -GO diff --git a/src/SFA.DAS.AssessorService.Database/Tables/APARSummary.sql b/src/SFA.DAS.AssessorService.Database/Tables/APARSummary.sql deleted file mode 100644 index de2f269ace..0000000000 --- a/src/SFA.DAS.AssessorService.Database/Tables/APARSummary.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE [dbo].[APARSummary] -( -[EndPointAssessorOrganisationId] nvarchar(12) NOT NULL, -[EndPointAssessorName] nvarchar(100) NOT NULL, -[EndPointAssessorUkprn] int NOT NULL, -[EarliestDateStandardApprovedOnRegister] datetime NOT NULL, -[EarliestEffectiveFromDate] datetime NOT NULL, -CONSTRAINT [PK_APARSummary] PRIMARY KEY CLUSTERED ([EndPointAssessorOrganisationId]) -); -Go - -CREATE UNIQUE INDEX [IXU_APARSummary] ON [dbo].[APARSummary] ([EndPointAssessorUkprn]) -INCLUDE ([EndPointAssessorOrganisationId],[EndPointAssessorName],[EarliestDateStandardApprovedOnRegister],[EarliestEffectiveFromDate]); -GO - diff --git a/src/SFA.DAS.AssessorService.Database/Tables/APARSummaryUpdated.sql b/src/SFA.DAS.AssessorService.Database/Tables/APARSummaryUpdated.sql deleted file mode 100644 index 0b86c97d52..0000000000 --- a/src/SFA.DAS.AssessorService.Database/Tables/APARSummaryUpdated.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE [dbo].[APARSummaryUpdated] -( -[LastUpdated] datetime NULL -); -GO \ No newline at end of file diff --git a/src/SFA.DAS.AssessorService.Shared/SFA.DAS.AssessorService.Shared.csproj b/src/SFA.DAS.AssessorService.Shared/SFA.DAS.AssessorService.Shared.csproj index 4d3a658bfb..9f10d2840d 100644 --- a/src/SFA.DAS.AssessorService.Shared/SFA.DAS.AssessorService.Shared.csproj +++ b/src/SFA.DAS.AssessorService.Shared/SFA.DAS.AssessorService.Shared.csproj @@ -49,7 +49,6 @@ - @@ -68,7 +67,6 @@ - @@ -187,8 +185,6 @@ - -