Below is a small service that collects event statuses from an external source and returns a summary for the API. In the current version, the logic does not work in all scenarios, and the regression needs to be fixed without changing the method contract.
collect method must accept Seq[String] with event identifiers and return Future[Map[String, Int]].fetchStatus(id: String): Future[Int] must be called and the sum of all successfully loaded values must be calculated.Future must complete with an error, not return a partial result.scala.concurrent.Future may be used.collect.fetchStatus calls fail with an exception.Example input data:
Seq("a", "b", "c")
Future.successful(Map(...)) with the correct sum should be returned.Futures fails, the final Future must be failed with the same cause.scala.concurrent.ExecutionContext.globalUse line comments to explain the problem, its impact, the fix and how to test it.