Skip to content

PSP-11710 : PIMS Notifications Panel not Displaying Reminders (BVT O…#5347

Merged
asanchezr merged 3 commits into
bcgov:testfrom
eddherrera:PSP-11710
Jun 30, 2026
Merged

PSP-11710 : PIMS Notifications Panel not Displaying Reminders (BVT O…#5347
asanchezr merged 3 commits into
bcgov:testfrom
eddherrera:PSP-11710

Conversation

@eddherrera

Copy link
Copy Markdown
Collaborator

…bservations) - HOTFIX

@eddherrera eddherrera self-assigned this Jun 29, 2026
@eddherrera eddherrera requested a review from asanchezr June 29, 2026 23:15
@github-actions

Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5347

Comment on lines +136 to +143
catch (Exception ex)
{
result.Status = ExternalResponseStatus.Error;
result.Message = $"Unexpected error sending CHES email: {ex.Message}";
_logger.LogError(ex, "Unexpected error sending CHES email.");

return result;
return result;
}
@github-actions

Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5347

@github-actions

Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5347

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

See CodeCov Report Here: https://app.codecov.io/github/bcgov/psp/pull/5347

@asanchezr asanchezr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved but see comments

}

public PimsNotificationUserOutput Update(PimsNotificationUserOutput userNotification)
public async Task<PimsNotificationUserOutput> Update(PimsNotificationUserOutput userNotification)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Naming conventions suggest to name async methods XYZAsync to let consumers know it is async. Can be done next sprint if no time now

https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/task-asynchronous-programming-model#naming-convention

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should do on a another version.

public async Task<PimsNotificationUserOutput> Update(PimsNotificationUserOutput userNotification)
{
try
var @lock = _synchronizationProvider.CreateLock("NotificationUserOutputLock");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A comment here goes a long way in explaining future developers why we put a lock in place here:

Suggested change
var @lock = _synchronizationProvider.CreateLock("NotificationUserOutputLock");
// Use a distributed lock to ensure that only one process can update the notification output table at a time (prevents deadlocks from history triggers).
var @lock = _synchronizationProvider.CreateLock("NotificationUserOutputLock");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not always if code if self explanatory.

.FirstOrDefault(x => x.NotificationUserOutputId == userNotification.NotificationUserOutputId);

Context.Entry(existingUserNotification).CurrentValues.SetValues(userNotification);
Context.Update(existingUserNotification);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if need the extra Update here since the line above updates the values via Context.Entry().CurrentValues

Also I see in the document queue they force the save in scope of the lock like so:

Context.SaveChanges(); // Force changes to be saved here, in the scope of the lock.

I would assume we need it here too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

tried it, didnt work. not needed.

if(filter.NotificationTriggerDate is not null)
{
predicateBuilder.And(x => x.NotificationUser.Notification.NotificationTriggerDate == filter.NotificationTriggerDate);
predicateBuilder.And(x => x.NotificationUser.Notification.NotificationTriggerDate <= filter.NotificationTriggerDate);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thank you for fixing this, but I think this query need an extra condition to exclude PRIOR notifications that have already been sent (sent_date !== null)

Suggested change
predicateBuilder.And(x => x.NotificationUser.Notification.NotificationTriggerDate <= filter.NotificationTriggerDate);
predicateBuilder.And(x => x.NotificationUser.Notification.NotificationTriggerDate <= filter.NotificationTriggerDate).And(x => x.NotificationSentDt == null);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Otherwise we risk the query returning ALL outputs from this day on (including all previously sent)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

NotificationSentDate == null is already in the predicate builder.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see

@mergify

mergify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@asanchezr asanchezr merged commit 9bea28f into bcgov:test Jun 30, 2026
19 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@eddherrera eddherrera deleted the PSP-11710 branch July 3, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants