From 886f26770c190ad29b9aa88fcaf345ccfcc5d427 Mon Sep 17 00:00:00 2001 From: Tony McCrae Date: Mon, 2 Dec 2024 21:50:23 +0000 Subject: [PATCH] Accept suggested improvement Co-authored-by: Andrew Nowak <10963046+andrew-nowak@users.noreply.github.com> --- cropper/app/lib/CropSpecMetadata.scala | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cropper/app/lib/CropSpecMetadata.scala b/cropper/app/lib/CropSpecMetadata.scala index f6875a5816..78e6c0a707 100644 --- a/cropper/app/lib/CropSpecMetadata.scala +++ b/cropper/app/lib/CropSpecMetadata.scala @@ -19,17 +19,10 @@ trait CropSpecMetadata { "height" -> dimensions.height, "aspect-ratio" -> r) - val nonEmptyMetadata = metadata.filter { - case (_, None) => false - case _ => true + metadata.collect { + case (key, Some(value)) => key -> value.toString + case (key, value) if value != None => key -> value.toString } - - val flattenedMetadata = nonEmptyMetadata.collect { - case (key, Some(value)) => key -> value - case (key, value) => key -> value - }.view.mapValues(_.toString).toMap - - flattenedMetadata } def cropSpecFromMetadata(userMetadata: Map[String, String]): Option[CropSpec] = {