in notification/app/notification/services/guardian/GuardianNotificationSender.scala [103:120]
def prepareBatch(notification: Notification, registrationCount: Option[Int], notificationReceivedTime: Instant): List[SendMessageBatchRequestEntry] = {
val countWithDefault: Int = registrationCount match {
case Some(count) => count
case None if notification.topic.exists(_.`type` == TopicTypes.Breaking) =>
logger.error("Unable to count registration for a list of topics during a breaking news, falling back on 1.5M")
1500000 // fallback on 1.5M: the worst case
case None =>
logger.error("Unable to count registration for a list of topics, falling back on 1")
1
}
shard(countWithDefault).map { shard =>
val shardedNotification = ShardedNotification(notification, shard, NotificationMetadata(notificationReceivedTime, registrationCount))
val payloadJson = Json.stringify(Json.toJson(shardedNotification))
val messageId = s"${notification.id}-${shard.start}-${shard.end}"
new SendMessageBatchRequestEntry(messageId, payloadJson)
}
}