Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Findeton committed Nov 23, 2024
1 parent c8f17e6 commit 80a766c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/controllers/ElectionsApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ object ElectionsApi
}

/** Future: deletes an election and its votes */
private def deleteElection(id: Long) = Future {
private def deleteElection(id: Long): Future[Result] = {
getElection(id)
.flatMap { election =>
val configJson = Json.parse(election.configuration)
Expand All @@ -1525,9 +1525,8 @@ object ElectionsApi
BadRequest(error(s"EO returned status ${resp.status} with body ${resp.body}", ErrorCodes.EO_ERROR))
}
}
}.flatMap { _ =>
Future.successful(DAL.elections.delete(id))
}.map { _ =>
DAL.elections.delete(id)
Ok(response("ok"))
}.recover {
case e: NoSuchElementException =>
Expand All @@ -1537,7 +1536,7 @@ object ElectionsApi
Logger.warn(s"Exception caught when deleting election: $t")
BadRequest(error(t.getMessage))
}
}(slickExecutionContext)
}


/** Future: updates an election's config */
Expand Down

0 comments on commit 80a766c

Please sign in to comment.