Skip to content

Commit

Permalink
Fixed spelling error
Browse files Browse the repository at this point in the history
Also increased expire time for notification
Moved dispatch of notifications events to status trigger
  • Loading branch information
FirestarJes committed Oct 29, 2024
1 parent cd1c7df commit 597d51a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ALTER TABLE [settlementreports].[SettlementReport]
ADD [IsNotficationSent] [bit] NOT NULL DEFAULT(1); --For all existing records, we will assume that notification has been sent.
ADD [IsNotificationSent] [bit] NOT NULL DEFAULT(1); --For all existing records, we will assume that notification has been sent.
GO

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Energinet.DataHub.Core.Messaging.Communication.Publisher;
using Energinet.DataHub.SettlementReport.Application.Handlers;
using Microsoft.Azure.Functions.Worker;

Expand All @@ -20,10 +21,14 @@ namespace Energinet.DataHub.SettlementReport.Orchestration.SettlementReports.Fun
internal sealed class SettlementReportUpdateStatusTimerTrigger
{
private readonly IListSettlementReportJobsHandler _listSettlementReportJobsHandler;
private readonly IPublisher _publisher;

public SettlementReportUpdateStatusTimerTrigger(IListSettlementReportJobsHandler listSettlementReportJobsHandler)
public SettlementReportUpdateStatusTimerTrigger(
IListSettlementReportJobsHandler listSettlementReportJobsHandler,
IPublisher publisher)
{
_listSettlementReportJobsHandler = listSettlementReportJobsHandler;
_publisher = publisher;
}

[Function(nameof(UpdateStatusForSettlementReports))]
Expand All @@ -32,7 +37,8 @@ public async Task UpdateStatusForSettlementReports(
FunctionContext executionContext)
{
// We are not interested in the result of the handler, as the handler will update the status of the settlement reports
// It will also handling sending Notifications to the expected recipients
// It will also handle sending Notifications to the expected recipients
await _listSettlementReportJobsHandler.HandleAsync().ConfigureAwait(false);
await _publisher.PublishAsync(executionContext.CancellationToken).ConfigureAwait(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public sealed class SettlementReport

public long? JobId { get; init; }

public bool IsNotficationSent { get; private set; }
public bool IsNotificationSent { get; private set; }

public SettlementReport(
IClock clock,
Expand All @@ -82,7 +82,7 @@ public SettlementReport(
SplitReportPerGridArea = request.SplitReportPerGridArea;
IncludeMonthlyAmount = request.IncludeMonthlyAmount;
GridAreas = JsonSerializer.Serialize(request.Filter.GridAreas);
IsNotficationSent = false;
IsNotificationSent = false;
}

public SettlementReport(
Expand All @@ -109,7 +109,7 @@ public SettlementReport(
SplitReportPerGridArea = request.SplitReportPerGridArea;
IncludeMonthlyAmount = request.IncludeMonthlyAmount;
GridAreas = JsonSerializer.Serialize(request.Filter.GridAreas);
IsNotficationSent = false;
IsNotificationSent = false;
}

// EF Core Constructor.
Expand Down Expand Up @@ -139,6 +139,6 @@ public void MarkAsFailed()

public void MarkAsNotificationSent()
{
IsNotficationSent = true;
IsNotificationSent = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Task<IntegrationEvent> CreateAsync(Application.SettlementReports_v2.Sett
TargetUserId = reportForNotification.UserId.ToString(),
RelatedId = reportForNotification.Id.ToString(),
OccurredAt = now.ToTimestamp(),
ExpiresAt = now.AddHours(23).ToTimestamp(),
ExpiresAt = now.AddDays(6).ToTimestamp(),
});

return Task.FromResult(integrationEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task DeleteAsync(Application.SettlementReports_v2.SettlementReport
public async Task<IEnumerable<Application.SettlementReports_v2.SettlementReport>> GetNeedsNotificationSentForCompletedAndFailed()
{
return await _context.SettlementReports
.Where(x => x.IsNotficationSent == false && (x.Status == SettlementReportStatus.Completed || x.Status == SettlementReportStatus.Failed))
.Where(x => x.IsNotificationSent == false && (x.Status == SettlementReportStatus.Completed || x.Status == SettlementReportStatus.Failed))
.OrderBy(x => x.EndedDateTime)
.ToListAsync()
.ConfigureAwait(false);
Expand Down

0 comments on commit 597d51a

Please sign in to comment.