Created
July 17, 2014 23:45
-
-
Save mmurray/752d794f69ebc572d584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
def fetchLatestActivityStats(orgCode: String): Future[String] = { | |
val yesterday = DateTime.now - 1.day | |
recursivelyLatestFetchActivityStats(yesterday, orgCode, 0) | |
} | |
def recursivelyLatestFetchActivityStats( | |
date: DateTime, org: String, errCount: Int): Future[String] = { | |
val key = "activity_stats/%s/%s/stats.json" | |
archiveBucket(key).map(fileItemOpt => { | |
fileItemOpt match { | |
case Some(fileItem) => date | |
case None => { | |
if (errCount >= 7) { | |
"-1" | |
} else { | |
val newDate = date - 1.day | |
val newErrCount = errCount + 1 | |
recursivelyLatestFetchActivityStats(newDate, org, newErrCount) | |
} | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment