Skip to content

Commit 19413ff

Browse files
authored
Merge pull request #6533 from espoon-voltti/fix-messages-to-ungrouped
Korjaus viestien lähettämiseen ryhmittämättömille lapsille
2 parents 859eb93 + d85c3a0 commit 19413ff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

service/src/main/kotlin/fi/espoo/evaka/messaging/MessageQueries.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ fun Database.Read.getMessageAccountsForRecipients(
14081408
recipients: List<MessageRecipient>
14091409
): Map<MessageRecipientType, List<Id<*>>> {
14101410
val recipientMap =
1411-
MessageRecipientType.values().associateWith { emptyList<Id<*>>() }.toMutableMap()
1411+
MessageRecipientType.entries.associateWith { emptyList<Id<*>>() }.toMutableMap()
14121412
recipients
14131413
.groupBy { it.type }
14141414
.forEach { (type, recipients) -> recipientMap[type] = recipients.map { it.id } }
@@ -1451,11 +1451,13 @@ WITH sender AS (
14511451
JOIN daycare d ON pl.unit_id = d.id
14521452
LEFT JOIN person p ON p.id = pl.child_id
14531453
LEFT JOIN service_need sn ON sn.placement_id = pl.placement_id AND daterange(sn.start_date, sn.end_date, '[]') @> ${bind(date)}
1454+
JOIN sender ON TRUE
14541455
WHERE (d.care_area_id = ANY(${bind(currentRecipients[MessageRecipientType.AREA])})
14551456
OR pl.unit_id = ANY(${bind(currentRecipients[MessageRecipientType.UNIT])})
14561457
OR pl.group_id = ANY(${bind(currentRecipients[MessageRecipientType.GROUP])})
14571458
OR pl.child_id = ANY(${bind(currentRecipients[MessageRecipientType.CHILD])}))
14581459
AND ${predicate(filterPredicates)}
1460+
AND (sender.type = 'MUNICIPAL'::message_account_type OR pl.group_id IS NOT NULL)
14591461
AND (
14601462
EXISTS (
14611463
SELECT 1
@@ -1486,12 +1488,14 @@ WITH sender AS (
14861488
LEFT JOIN daycare_group_placement dgp ON pl.id = dgp.daycare_placement_id
14871489
LEFT JOIN person p ON p.id = pl.child_id
14881490
LEFT JOIN service_need sn ON false
1491+
JOIN sender ON TRUE
14891492
WHERE (pl.start_date > ${bind(date)} OR dgp.start_date > ${bind(date)})
14901493
AND (d.care_area_id = ANY(${bind(starterRecipients[MessageRecipientType.AREA])})
14911494
OR pl.unit_id = ANY(${bind(starterRecipients[MessageRecipientType.UNIT])})
14921495
OR dgp.daycare_group_id = ANY(${bind(starterRecipients[MessageRecipientType.GROUP])})
14931496
OR pl.child_id = ANY(${bind(starterRecipients[MessageRecipientType.CHILD])}))
14941497
AND ${predicate(filterPredicates)}
1498+
AND (sender.type = 'MUNICIPAL'::message_account_type OR dgp.daycare_group_id IS NOT NULL)
14951499
AND (
14961500
EXISTS (
14971501
SELECT 1

0 commit comments

Comments
 (0)