in app/services/FaciaPress.scala [80:131]
def press(pressCommand: PressCommand): Future[List[PublishResult]] = {
configAgent.refreshAndReturn() flatMap { _ =>
val paths: Set[String] = for {
id <- pressCommand.collectionIds
path <- configAgent.getConfigsUsingCollectionId(id)
} yield path
val pathToCollectionIdsLookup = configAgent.getConfigCollectionMap
def sendEvents(pressType: PressType) = Future.traverse(
paths.filter(_ =>
pressType match {
case Live => pressCommand.live
case Draft => pressCommand.draft
}
)
) { path =>
val event = PressJob(
FrontPath(path),
pressType,
forceConfigUpdate = pressCommand.forceConfigUpdate
)
val collectionIdsRelevantToPath =
pressCommand.collectionIds.filter(collectionId => {
pathToCollectionIdsLookup.get(path).exists(_.contains(collectionId))
})
val publishResultFuture =
faciaPressTopic.publish(event, collectionIdsRelevantToPath)
publishResultFuture.onComplete {
case Failure(error) =>
logger.error(
s"Error publishing to the SNS topic, $pressType event: $event",
error
)
EnqueuePressFailure.increment()
case Success(_) =>
logger.info(s"Published to the SNS topic, $pressType event: $event")
EnqueuePressSuccess.increment()
}
publishResultFuture
}
for {
live <- sendEvents(Live)
draft <- sendEvents(Draft)
} yield (live ++ draft).toList
}
}