Skip to content

Commit

Permalink
Do not notify about a GFI that has already been notified
Browse files Browse the repository at this point in the history
  • Loading branch information
ofux committed Nov 21, 2024
1 parent 224b0f0 commit 3e1710c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,11 @@ void should_notify_users_on_new_good_first_issues() throws InterruptedException
.withRequestBody(matchingJsonPath("$.subject", equalTo("New good first issue"))));

customerIOWireMockServer.verify(2, postRequestedFor(urlEqualTo("/send/email")));
customerIOWireMockServer.resetAll();

// Check that notification for a single issue is sent only once
goodFirstIssueCreatedNotifierJob.run();
Thread.sleep(1000L);
customerIOWireMockServer.verify(0, postRequestedFor(urlEqualTo("/send/email")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface GithubIssueViewRepository extends Repository<GithubIssueViewEnt
and gi.status = 'OPEN'
and gia.user_id is null
and NOT exists(SELECT 1 FROM hackathon_issues hi WHERE hi.issue_id = gi.id)
and NOT exists(SELECT 1 FROM iam.notifications n WHERE n.data->'notification'->>'@type' = 'GoodFirstIssueCreated'
AND cast(n.data->'notification'->'issue'->>'id' as bigint) = gi.id)
""", nativeQuery = true)
List<GithubIssueViewEntity> findAllGoodFirstIssuesCreatedSince5Minutes(ZonedDateTime now, String timezone);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create index if not exists notifications_data_notification_type_index
on iam.notifications ((data -> 'notification' ->> '@type'));

create index if not exists notifications_data_notification_issue_id_index
on iam.notifications ((cast(data -> 'notification' -> 'issue' ->> 'id' as bigint)));
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ databaseChangeLog:
file: db/changelog/changelogs/00000026_add_missing_indexes.sql
- include:
file: db/changelog/changelogs/00000027_restore_indexes.sql
- include:
file: db/changelog/changelogs/00000028_add_indexes.sql

0 comments on commit 3e1710c

Please sign in to comment.