|
|
@@ -10,7 +10,7 @@ object Extract {
|
|
|
"Atlanta Hawks",
|
|
|
"Los Angeles Lakers",
|
|
|
"Milwaukee Bucks"
|
|
|
- ).take(1)
|
|
|
+ ).take(4)
|
|
|
|
|
|
def writeOrReadBack[T: ReadWriter](
|
|
|
file: os.Path,
|
|
|
@@ -22,6 +22,7 @@ object Extract {
|
|
|
|
|
|
data
|
|
|
} else {
|
|
|
+ println(s"file $file already exists, reading back from it")
|
|
|
Utils.readFromFile[T](file)
|
|
|
}
|
|
|
}
|
|
|
@@ -36,20 +37,19 @@ object Extract {
|
|
|
writeOrReadBack(output, getData)
|
|
|
}
|
|
|
|
|
|
- def getStats(stats_output: os.Path, games_output: os.Path) = {
|
|
|
- if (!os.exists(stats_output) || !os.exists(games_output)) {
|
|
|
- val teamIds = EndpointResponse
|
|
|
- .getTeams()
|
|
|
- .filter(team => selectedTeams.contains(team.full_name))
|
|
|
- .map(_.id)
|
|
|
- val gameList = EndpointResponse.getGames(2021, teamIds)
|
|
|
+ def getGames(output: os.Path, season: Int, teamIds: List[Int]) = {
|
|
|
+ def getData() = {
|
|
|
+ EndpointResponse.getGames(2021, teamIds)
|
|
|
+ }
|
|
|
|
|
|
- val stats = EndpointResponse.getStats(gameList.map(_.id))
|
|
|
+ writeOrReadBack(output, getData)
|
|
|
+ }
|
|
|
|
|
|
- Utils.writeToFile(PlayerGameStats.as_json_value(stats), stats_output)
|
|
|
- Utils.writeToFile(gameList, games_output)
|
|
|
- } else {
|
|
|
- println(s"output files $stats_output and $games_output already exist")
|
|
|
+ def getStats(output: os.Path, gameIds: List[Int]) = {
|
|
|
+ def getData() = {
|
|
|
+ EndpointResponse.getStats(gameIds)
|
|
|
}
|
|
|
+
|
|
|
+ writeOrReadBack(output, getData)
|
|
|
}
|
|
|
}
|