diff --git a/housekeeping/src/main/groovy/whelk/housekeeping/NotificationSender.groovy b/housekeeping/src/main/groovy/whelk/housekeeping/NotificationSender.groovy index 6446e808e5..77522c76ac 100644 --- a/housekeeping/src/main/groovy/whelk/housekeeping/NotificationSender.groovy +++ b/housekeeping/src/main/groovy/whelk/housekeeping/NotificationSender.groovy @@ -227,19 +227,23 @@ class NotificationSender extends HouseKeeper { else sb.append("\n") - Object comments = Document._get(["@graph", 1, "comment"], observation) - - if (comments instanceof List) { - sb.append("\n\tTillhörande kommentarer:") - for (String comment : comments) - sb.append("\n\t\t"+comment) - } - + boolean commentsRendered = false for (Map observation : triggeredObservations) { String observationUri = Document._get(["@graph", 1, "@id"], observation) if (!observationUri) continue + if (!commentsRendered) { + commentsRendered = true + Object comments = Document._get(["@graph", 1, "comment"], observation) + + if (comments instanceof List) { + sb.append("\n\tTillhörande kommentarer:") + for (String comment : comments) + sb.append("\n\t\t" + comment + "\n\n") + } + } + String observationId = whelk.getStorage().getSystemIdByIri(observationUri) Document embellishedObservation = whelk.loadEmbellished(observationId) Map framed = JsonLd.frame(observationUri, embellishedObservation.data)