From cf1d2fd2320e4afbc38991d49e01db0f84972a44 Mon Sep 17 00:00:00 2001 From: Michael <52096428+michaelmajgaard@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:05:41 +0100 Subject: [PATCH] Revert "feat: settlement report - include previous grid owners (#73)" (#74) This reverts commit f7d0fc3eae5722c5eea4c960aa099f46b9507e07. --- .../RequestSettlementReportHandler.cs | 54 +------------------ .../Model/ActorNumber.cs | 2 +- .../Model/GridAreaCode.cs | 2 +- .../Model/GridAreaOwner.cs | 2 +- .../Services/GridAreaOwnerRepository.cs | 3 +- .../Services/IGridAreaOwnerRepository.cs | 4 +- .../GridAreaOwnerRepositoryTests.cs | 2 +- .../RequestSettlementReportHandlerTests.cs | 3 +- .../SettlementReportModuleExtensions.cs | 1 - 9 files changed, 10 insertions(+), 63 deletions(-) rename source/settlement-report/{SettlementReports.Application => SettlementReports.Infrastructure}/Model/ActorNumber.cs (90%) rename source/settlement-report/{SettlementReports.Application => SettlementReports.Infrastructure}/Model/GridAreaCode.cs (90%) rename source/settlement-report/{SettlementReports.Application => SettlementReports.Infrastructure}/Model/GridAreaOwner.cs (91%) rename source/settlement-report/{SettlementReports.Application => SettlementReports.Infrastructure}/Services/IGridAreaOwnerRepository.cs (85%) diff --git a/source/settlement-report/SettlementReports.Application/Handlers/RequestSettlementReportHandler.cs b/source/settlement-report/SettlementReports.Application/Handlers/RequestSettlementReportHandler.cs index 731e377..eb89afd 100644 --- a/source/settlement-report/SettlementReports.Application/Handlers/RequestSettlementReportHandler.cs +++ b/source/settlement-report/SettlementReports.Application/Handlers/RequestSettlementReportHandler.cs @@ -13,12 +13,9 @@ // limitations under the License. using Energinet.DataHub.SettlementReport.Application.Commands; -using Energinet.DataHub.SettlementReport.Application.Model; -using Energinet.DataHub.SettlementReport.Application.Services; using Energinet.DataHub.SettlementReport.Interfaces.Helpers; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2.Models; -using NodaTime.Extensions; namespace Energinet.DataHub.SettlementReport.Application.Handlers; @@ -26,66 +23,19 @@ public sealed class RequestSettlementReportHandler : IRequestSettlementReportJob { private readonly IDatabricksJobsHelper _jobHelper; private readonly ISettlementReportInitializeHandler _settlementReportInitializeHandler; - private readonly IGridAreaOwnerRepository _gridAreaOwnerRepository; public RequestSettlementReportHandler( IDatabricksJobsHelper jobHelper, - ISettlementReportInitializeHandler settlementReportInitializeHandler, - IGridAreaOwnerRepository gridAreaOwnerRepository) + ISettlementReportInitializeHandler settlementReportInitializeHandler) { _jobHelper = jobHelper; _settlementReportInitializeHandler = settlementReportInitializeHandler; - _gridAreaOwnerRepository = gridAreaOwnerRepository; } public async Task HandleAsync(RequestSettlementReportCommand request) - { - if (request.MarketRole == MarketRole.GridAccessProvider) - { - JobRunId? firstRunId = null; - - var gridAreas = request.RequestDto.Filter.GridAreas.Select(x => x.Key); - - var distinctOwners = await GetGridAreaOwnersAsync(gridAreas, request.RequestDto.Filter).ConfigureAwait(false); - - foreach (var owner in distinctOwners) - { - var id = await StartReportAsync(request, owner.Value).ConfigureAwait(false); - firstRunId ??= id; - } - - return firstRunId!; - } - - return await StartReportAsync(request, request.ActorGln).ConfigureAwait(false); - } - - private async Task> GetGridAreaOwnersAsync(IEnumerable gridAreaCodes, SettlementReportRequestFilterDto filter) - { - var gridAreaOwners = new HashSet(); - - foreach (var grid in gridAreaCodes) - { - var owners = await _gridAreaOwnerRepository.GetGridAreaOwnersAsync( - new GridAreaCode(grid), - filter.PeriodStart.ToInstant(), - filter.PeriodEnd.ToInstant()).ConfigureAwait(false); - - foreach (var owner in owners) - { - gridAreaOwners.Add(owner.ActorNumber); - } - } - - return gridAreaOwners; - } - - private async Task StartReportAsync(RequestSettlementReportCommand request, string requestActorGln) { var reportId = new SettlementReportRequestId(Guid.NewGuid().ToString()); - - var runId = await _jobHelper.RunSettlementReportsJobAsync(request.RequestDto, request.MarketRole, reportId, requestActorGln).ConfigureAwait(false); - + var runId = await _jobHelper.RunSettlementReportsJobAsync(request.RequestDto, request.MarketRole, reportId, request.ActorGln).ConfigureAwait(false); await _settlementReportInitializeHandler .InitializeFromJobAsync( request.UserId, diff --git a/source/settlement-report/SettlementReports.Application/Model/ActorNumber.cs b/source/settlement-report/SettlementReports.Infrastructure/Model/ActorNumber.cs similarity index 90% rename from source/settlement-report/SettlementReports.Application/Model/ActorNumber.cs rename to source/settlement-report/SettlementReports.Infrastructure/Model/ActorNumber.cs index fb13c53..a373678 100644 --- a/source/settlement-report/SettlementReports.Application/Model/ActorNumber.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Model/ActorNumber.cs @@ -12,6 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Energinet.DataHub.SettlementReport.Application.Model; +namespace Energinet.DataHub.SettlementReport.Infrastructure.Model; public sealed record ActorNumber(string Value); diff --git a/source/settlement-report/SettlementReports.Application/Model/GridAreaCode.cs b/source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaCode.cs similarity index 90% rename from source/settlement-report/SettlementReports.Application/Model/GridAreaCode.cs rename to source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaCode.cs index d2a2ccb..45aa255 100644 --- a/source/settlement-report/SettlementReports.Application/Model/GridAreaCode.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaCode.cs @@ -12,6 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Energinet.DataHub.SettlementReport.Application.Model; +namespace Energinet.DataHub.SettlementReport.Infrastructure.Model; public sealed record GridAreaCode(string Value); diff --git a/source/settlement-report/SettlementReports.Application/Model/GridAreaOwner.cs b/source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaOwner.cs similarity index 91% rename from source/settlement-report/SettlementReports.Application/Model/GridAreaOwner.cs rename to source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaOwner.cs index d1e8dfe..012c74d 100644 --- a/source/settlement-report/SettlementReports.Application/Model/GridAreaOwner.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Model/GridAreaOwner.cs @@ -14,6 +14,6 @@ using NodaTime; -namespace Energinet.DataHub.SettlementReport.Application.Model; +namespace Energinet.DataHub.SettlementReport.Infrastructure.Model; public sealed record GridAreaOwner(GridAreaCode Code, ActorNumber ActorNumber, Instant ValidFrom); diff --git a/source/settlement-report/SettlementReports.Infrastructure/Services/GridAreaOwnerRepository.cs b/source/settlement-report/SettlementReports.Infrastructure/Services/GridAreaOwnerRepository.cs index 75e0494..822ea12 100644 --- a/source/settlement-report/SettlementReports.Infrastructure/Services/GridAreaOwnerRepository.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Services/GridAreaOwnerRepository.cs @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Energinet.DataHub.SettlementReport.Application.Model; -using Energinet.DataHub.SettlementReport.Application.Services; using Energinet.DataHub.SettlementReport.Infrastructure.Contracts; +using Energinet.DataHub.SettlementReport.Infrastructure.Model; using Energinet.DataHub.SettlementReport.Infrastructure.Persistence; using Microsoft.EntityFrameworkCore; using NodaTime; diff --git a/source/settlement-report/SettlementReports.Application/Services/IGridAreaOwnerRepository.cs b/source/settlement-report/SettlementReports.Infrastructure/Services/IGridAreaOwnerRepository.cs similarity index 85% rename from source/settlement-report/SettlementReports.Application/Services/IGridAreaOwnerRepository.cs rename to source/settlement-report/SettlementReports.Infrastructure/Services/IGridAreaOwnerRepository.cs index 9214b1d..834b84b 100644 --- a/source/settlement-report/SettlementReports.Application/Services/IGridAreaOwnerRepository.cs +++ b/source/settlement-report/SettlementReports.Infrastructure/Services/IGridAreaOwnerRepository.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Energinet.DataHub.SettlementReport.Application.Model; +using Energinet.DataHub.SettlementReport.Infrastructure.Model; using NodaTime; -namespace Energinet.DataHub.SettlementReport.Application.Services; +namespace Energinet.DataHub.SettlementReport.Infrastructure.Services; public interface IGridAreaOwnerRepository { diff --git a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/GridAreaOwnerRepositoryTests.cs b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/GridAreaOwnerRepositoryTests.cs index d8f97c3..5dace58 100644 --- a/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/GridAreaOwnerRepositoryTests.cs +++ b/source/settlement-report/SettlementReports.IntegrationTests/Infrastructure/SettlementReports_v2/Persistence/GridAreaOwnerRepositoryTests.cs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Energinet.DataHub.SettlementReport.Application.Model; using Energinet.DataHub.SettlementReport.Infrastructure.Contracts; +using Energinet.DataHub.SettlementReport.Infrastructure.Model; using Energinet.DataHub.SettlementReport.Infrastructure.Persistence; using Energinet.DataHub.SettlementReport.Infrastructure.Services; using Energinet.DataHub.SettlementReport.Test.Core.Fixture.Database; diff --git a/source/settlement-report/SettlementReports.UnitTests/Handlers/RequestSettlementReportHandlerTests.cs b/source/settlement-report/SettlementReports.UnitTests/Handlers/RequestSettlementReportHandlerTests.cs index b41bed3..3835996 100644 --- a/source/settlement-report/SettlementReports.UnitTests/Handlers/RequestSettlementReportHandlerTests.cs +++ b/source/settlement-report/SettlementReports.UnitTests/Handlers/RequestSettlementReportHandlerTests.cs @@ -15,7 +15,6 @@ using System.Collections.ObjectModel; using Energinet.DataHub.SettlementReport.Application.Commands; using Energinet.DataHub.SettlementReport.Application.Handlers; -using Energinet.DataHub.SettlementReport.Application.Services; using Energinet.DataHub.SettlementReport.Interfaces.Helpers; using Energinet.DataHub.SettlementReport.Interfaces.Models; using Energinet.DataHub.SettlementReport.Interfaces.SettlementReports_v2; @@ -56,7 +55,7 @@ public async Task Handle_ValidRequest_ReturnsJobId() .ReturnsAsync(jobRunId); var command = new RequestSettlementReportCommand(request, Guid.NewGuid(), Guid.NewGuid(), true, "1233", MarketRole.EnergySupplier); - var handler = new RequestSettlementReportHandler(jobHelperMock.Object, initializerMock.Object, new Mock().Object); + var handler = new RequestSettlementReportHandler(jobHelperMock.Object, initializerMock.Object); // Act var result = await handler.HandleAsync(command); diff --git a/source/settlement-report/SettlementReports.WebAPI/Extensions/DependencyInjection/SettlementReportModuleExtensions.cs b/source/settlement-report/SettlementReports.WebAPI/Extensions/DependencyInjection/SettlementReportModuleExtensions.cs index ff2dd8c..9b11c88 100644 --- a/source/settlement-report/SettlementReports.WebAPI/Extensions/DependencyInjection/SettlementReportModuleExtensions.cs +++ b/source/settlement-report/SettlementReports.WebAPI/Extensions/DependencyInjection/SettlementReportModuleExtensions.cs @@ -14,7 +14,6 @@ using Energinet.DataHub.Core.App.Common.Extensions.DependencyInjection; using Energinet.DataHub.SettlementReport.Application.Handlers; -using Energinet.DataHub.SettlementReport.Application.Services; using Energinet.DataHub.SettlementReport.Application.SettlementReports_v2; using Energinet.DataHub.SettlementReport.Common.Infrastructure.Extensions.Options; using Energinet.DataHub.SettlementReport.Common.Infrastructure.HealthChecks;