Skip to content

Instantly share code, notes, and snippets.

@dhoss
Created August 6, 2015 16:38
Show Gist options
  • Save dhoss/b5c14840923e0b863cec to your computer and use it in GitHub Desktop.
Save dhoss/b5c14840923e0b863cec to your computer and use it in GitHub Desktop.
def crawlProjectRepos(project: String) = {
Logger.info("crawling " + project + " by API")
// a list of Futures containing a Tuple2 of a repository name and a Future[WSResponse]
val repoList = reposFor(project).map { repo =>
(repo, callApi(buildCommitUrl(project, repo)))
}
Logger.debug("REPOS FOR" + reposFor(project))
Future.traverse(repoList) (
repoCommits =>
repoCommits._2.filter(_.status==200).map { res =>
(res.json \ "values").as[List[JsValue]].map { c =>
Commit(0,
(c \ "id").as[String],
(c \ "message").as[String],
(c \ "author" \ "name").as[String],
(c \ "author" \ "emailAddress").as[String],
(c \ "authorTimestamp").as[Option[DateTime]](Reads.optionWithNull(jodaDateReads("yyyy-MM-dd'T'HH:mm:ss'Z"))),
repoCommits._1,
Option(new DateTime),
Option(new DateTime)
)}
}).map(_.flatten)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment