From d7181fe08cb50ddaae57ed52c15154d0b8f9bc30 Mon Sep 17 00:00:00 2001 From: Oliver <20188437+olivergrabinski@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:04:06 +0200 Subject: [PATCH] Try out for comprehension for clarity --- .../compositeviews/CompositeSink.scala | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala index 2a4eb6e7f7..eb1baef92e 100644 --- a/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala +++ b/delta/plugins/composite-views/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/compositeviews/CompositeSink.scala @@ -123,19 +123,20 @@ final class Batch[SinkFormat]( } override def apply(elements: Chunk[Elem[GraphResource]]): Task[Chunk[Elem[Unit]]] = - query(elements) - .flatMap { - case Some(fullGraph) => - elements.traverse { elem => - elem.evalMapFilter { gr => - replaceGraph(gr, fullGraph).flatMap(transform) - } - } - case None => - Task.pure(elements.map(_.drop)) - } - .flatMap(sink) -} + for { + graph <- query(elements) + transformed <- graph match { + case Some(fullGraph) => + elements.traverse { elem => + elem.evalMapFilter { gr => + replaceGraph(gr, fullGraph).flatMap(transform) + } + } + case None => + Task.pure(elements.map(_.drop)) + } + sank <- sink(transformed) + } yield sank object CompositeSink {