Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reminder emails functionality #279

Merged
merged 17 commits into from
Apr 29, 2024
Merged

Add reminder emails functionality #279

merged 17 commits into from
Apr 29, 2024

Conversation

jungwire
Copy link
Contributor

@jungwire jungwire commented Apr 10, 2024

Negotiator pull request:

Description:

Introduces some changes to the notification email service by adding a functionality to send reminder emails for pending (negotiations that are under review) and stale (negotiations without ) to admins and representatives, respectively. The goal is to increase the responsiveness of biobanks/admins.

Checklist:

Make sure you tick all the boxes bellow if they are true or do not apply:

  • I have performed a self review of my code
  • My code follows Google Java Code style
  • I have made my code as simple as possible
  • I have added unit tests and the code coverage has not decreased
  • I have updated the documentation in all relevant places

@jungwire jungwire linked an issue Apr 10, 2024 that may be closed by this pull request
1 task
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 94.50549% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 80.00%. Comparing base (e276f5c) to head (171e2fc).

Files Patch % Lines
...egotiator/service/UserNotificationServiceImpl.java 94.50% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #279      +/-   ##
============================================
+ Coverage     79.94%   80.00%   +0.05%     
- Complexity     1006     1020      +14     
============================================
  Files           136      136              
  Lines          3017     3095      +78     
  Branches        163      170       +7     
============================================
+ Hits           2412     2476      +64     
- Misses          505      516      +11     
- Partials        100      103       +3     
Flag Coverage Δ
unit 80.00% <94.50%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jungwire jungwire marked this pull request as ready for review April 15, 2024 11:43
Copy link
Collaborator

@RadovanTomik RadovanTomik left a comment

Choose a reason for hiding this comment

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

why not just implement a nightly cron method that goes through all Negotiations created e.g. a week ago, looks at what resouces have had at least one status update and sends a notification to reps of those that didn't have an update?

Copy link
Collaborator

@RadovanTomik RadovanTomik left a comment

Choose a reason for hiding this comment

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

Please see commments


private static LocalDateTime thresholdTime;

private static Collection<NegotiationResourceState> activeNegotiationResourceStates =
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not do it the other way? nonActiveResource states are just Unavailable and Made available


@Value("${negotiator.frontend-url}")
private String frontendUrl;

@Value("${reminder.trigger-duration-days:P14D}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

thinking about it now, change to 7 days

@@ -51,6 +75,29 @@ private static Set<Person> getRepresentativesForNegotiation(Negotiation negotiat
.collect(Collectors.toSet());
}

private static Set<Person> getRepresentativesForStaleNegotiation(Negotiation negotiation) {
Set<Person> representatives =
Copy link
Collaborator

Choose a reason for hiding this comment

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

first you should just get resources involved in the Negotiation that did not have a new record in the last week/2 week. Then simply get their reps


@Test
@WithMockNegotiatorUser(id = 109L, roles = "ADMIN")
public void testSendReminderEmails() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure one test is enough for this. You should check multiple scenarios: for example set trigger duration to 0ms and then check if correct notifications were made

@@ -31,6 +31,10 @@ public class NegotiationResourceLifecycleRecord extends AuditEntity {
@JoinColumn(name = "resource_id", referencedColumnName = "id")
private Resource resource;

@ManyToOne
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure this is needed. Just go through the parent entity, if this is needed you need a migration script no?

@RadovanTomik
Copy link
Collaborator

technically I think it is implemented correctly, @konradlang do you think it matches the desired functionality?

@jungwire jungwire merged commit c70f0e7 into master Apr 29, 2024
17 checks passed
@jungwire jungwire deleted the feat/reminder-emails branch April 29, 2024 12:34
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.

[FEATURE] Add mechanism for reminder emails
3 participants