Skip to content

Commit

Permalink
refactor: Small refactoring (#3311)
Browse files Browse the repository at this point in the history
  • Loading branch information
BalduinLandolt authored Jul 9, 2024
1 parent d2f2120 commit 6822d16
Showing 1 changed file with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -634,30 +634,20 @@ final case class ResourcesResponderV2(
}

// Check if resources are deleted, if so, replace them with DeletedResource
responseWithDeletedResourcesReplaced = apiResponse.resources match {
case resourceList =>
if (resourceList.nonEmpty) {
val resourceListWithDeletedResourcesReplaced = resourceList.map {
resource =>
resource.deletionInfo match {
// Resource deleted -> return DeletedResource instead
case Some(_) => resource.asDeletedResource()
// Resource not deleted -> return resource
case None =>
// deleted values should be shown -> resource can be returned
if (showDeletedValues) resource
// deleted Values should not be shown -> replace them with generic DeletedValue
else resource.withDeletedValues()
}
}
apiResponse.copy(resources =
resourceListWithDeletedResourcesReplaced,
)
} else {
apiResponse
}
}

deletedResourcesReplaced =
apiResponse.resources.map { case resource =>
resource.deletionInfo match {
// Resource deleted -> return DeletedResource instead
case Some(_) => resource.asDeletedResource()
// Resource not deleted -> return resource
case None =>
// deleted values should be shown -> resource can be returned
if (showDeletedValues) resource
// deleted Values should not be shown -> replace them with generic DeletedValue
else resource.withDeletedValues()
}
}
responseWithDeletedResourcesReplaced = apiResponse.copy(resources = deletedResourcesReplaced)
} yield responseWithDeletedResourcesReplaced

}
Expand Down

0 comments on commit 6822d16

Please sign in to comment.