Skip to content

Instantly share code, notes, and snippets.

@dhoss
Created July 29, 2015 18:48
Show Gist options
  • Save dhoss/e4c1b2698935f89422ee to your computer and use it in GitHub Desktop.
Save dhoss/e4c1b2698935f89422ee to your computer and use it in GitHub Desktop.
skip if status != 200
// we want to be asynchronous here because we are doing several API calls
def crawlProjectRepos(project: String):Future[RepositoryCommitList] = {
Logger.info("crawling " + project + " by API")
val repos = reposFor(project)
val commitList:scala.collection.mutable.ListBuffer[Commit] = scala.collection.mutable.ListBuffer[Commit]()
val commits = for {
repo <- repos;
c <- callApi(buildCommitUrl(project, repo));
rc <- breakable {
if ( c.status != 200 ) {
break
} else {
RepositoryCommitList(repo, (c.json \ "values").as[List[JsValue]].map { commit =>
Commit(0,
(commit \ "id").as[String],
(commit \ "message").as[String],
(commit \ "author" \ "name").as[String],
(commit \ "author" \ "emailAddress").as[String],
(commit \ "authorTimestamp").as[Option[DateTime]](Reads.optionWithNull(jodaDateReads("yyyy-MM-dd'T'HH:mm:ss'Z"))),
None,
Option(new DateTime),
Option(new DateTime)
)
})
}
}
} yield rc
// create a Future.sequence to make sure the requests are run in parallel
// and then run them, returning a Future
Future.sequence(commits)
}
Compilation error
value map is not a member of Unit
In /home/devin/projects/blaster/app/clients/Stash.scala:67
64 val commits = for {
65 repo <- repos ;
66 c <- callApi(buildCommitUrl(project, repo));
67 rc <- breakable {
68 if ( c.status != 200 ) {
69 break
70 } else {
71 RepositoryCommitList(repo, (c.json \ "values").as[List[JsValue]].map { commit =>
72 Commit(0,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment