Skip to content

Commit 2f924b1

Browse files
authored
Merge pull request #5747
FINERACT-2582: Move constant repository lookups outside loops in email campaign and notification services
2 parents 1c59ecb + 57283fe commit 2f924b1

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

fineract-provider/src/main/java/org/apache/fineract/infrastructure/campaigns/jobs/updateemailoutboundwithcampaignmessage/UpdateEmailOutboundWithCampaignMessageTasklet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ private void insertDirectCampaignIntoEmailOutboundTable(final String emailParams
9090
List<HashMap<String, Object>> runReportObject = emailCampaignWritePlatformService
9191
.getRunReportByServiceImpl(campaignParams.get("reportName"), queryParamForRunReport);
9292
if (runReportObject != null) {
93+
EmailCampaign emailCampaign = emailCampaignRepository.findById(campaignId).orElse(null);
9394
for (HashMap<String, Object> entry : runReportObject) {
9495
String message = compileEmailTemplate(messageTemplate, campaignName, entry);
9596
Integer clientId = (Integer) entry.get("id");
96-
EmailCampaign emailCampaign = emailCampaignRepository.findById(campaignId).orElse(null);
9797
Client client = clientRepositoryWrapper.findOneWithNotFoundDetection(clientId.longValue());
9898
String emailAddress = client.emailAddress();
9999

fineract-provider/src/main/java/org/apache/fineract/notification/service/NotificationWritePlatformServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public Long notify(Collection<Long> userIds, String objectType, Long objectId, S
6161

6262
private List<Long> insertIntoNotificationMapper(Collection<Long> userIds, Long generatedNotificationId) {
6363
List<Long> mappedIds = new ArrayList<>();
64+
Notification notification = this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId);
6465
for (Long userId : userIds) {
6566
AppUser appUser = this.appUserRepository.findById(userId).orElseThrow();
66-
NotificationMapper notificationMapper = new NotificationMapper()
67-
.setNotification(this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId)).setUserId(appUser)
68-
.setRead(false).setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
67+
NotificationMapper notificationMapper = new NotificationMapper().setNotification(notification).setUserId(appUser).setRead(false)
68+
.setCreatedAt(DateUtils.getLocalDateTimeOfSystem());
6969
this.notificationMapperWritePlatformService.create(notificationMapper);
7070
mappedIds.add(notificationMapper.getId());
7171
}

0 commit comments

Comments
 (0)