Skip to content

Instantly share code, notes, and snippets.

@gbougeard
Last active August 29, 2015 13:58
Show Gist options
  • Save gbougeard/10017042 to your computer and use it in GitHub Desktop.
Save gbougeard/10017042 to your computer and use it in GitHub Desktop.
Use zip to find errors refs
val futures = for {
o <- Future.sequence(list.map(Jira.getIssue))
} yield o
futures.map(results => {
val jsonIssues: List[Option[Issue]] = results.map(result => {
result.json.validate[Issue] match {
case s: JsSuccess[Issue] => Some(s.get)
case e: JsError => {
Logger.debug("Errors: " + JsError.toFlatJson(e).toString())
None
}
}
})
val issues:List[(Option[Issue], String)] = jsonIssues zip list
issues.filter(_._1 == None).map(r => Logger.debug(s"ref $r not found"))
// ).collect {
// case Some(i) => i
// }
// play.Logger.debug(s"$jsonIssues")
val releaseNote = new ReleaseNote(ref,
jsonIssues.flatten.filter(_.key.startsWith("RIT")).distinct.groupBy(_.custId),
jsonIssues.flatten.filter(_.key.startsWith("BUG")).distinct.groupBy(_.custId),
commits)
Ok(views.html.releaseNotes(releaseNote))
})
@gbougeard
Copy link
Author

@Ugo je n'ai pas encore l'habitude de jouer avec les Either. Je ne suis qu'un part-time scalafist :'(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment