in app/controllers/Admin.scala [50:72]
def getSectionMappings(
selectedDeskIdOption: Option[Long],
sectionListFromDB: List[Section],
deskList: List[Desk]):
Future[List[Section]] = {
val selectedDeskOption = for {
selectedDeskId <- selectedDeskIdOption
selectedDesk <- deskList.find((desk) => selectedDeskId == desk.id)
} yield {
selectedDesk
}
selectedDeskOption.map { selectedDesk =>
sectionDeskMappingsAPI
.getSectionsWithRelation(selectedDesk, sectionListFromDB)
.asFuture
.map {
case Right(relations) => relations
case Left(err) => logger.error(s"unable to fetch the sections in the relation: $err")
List()
}
}.getOrElse(Future(sectionListFromDB))
}