|
|
@@ -19,7 +19,7 @@ object ResponseMetadata {
|
|
|
object Utils {
|
|
|
def get_and_decode[T: Reader](
|
|
|
endpoint: String,
|
|
|
- params: Map[String, Any] = Map()
|
|
|
+ params: List[(String, Any)] = List()
|
|
|
): T = {
|
|
|
println(endpoint, params)
|
|
|
val r = requests.get(
|
|
|
@@ -60,18 +60,18 @@ object EndpointResponse {
|
|
|
val teams_per_page = 25
|
|
|
val games_per_page = 25
|
|
|
val stats_per_page = 25
|
|
|
- val stats_page_limit = 20
|
|
|
+ val stats_page_limit = 2
|
|
|
|
|
|
def doPaginatedRequest[T: Reader](
|
|
|
endpoint: String,
|
|
|
page: Int,
|
|
|
per_page: Int,
|
|
|
- params: Map[String, Any] = Map()
|
|
|
+ params: List[(String, Any)] = List()
|
|
|
) = {
|
|
|
Utils
|
|
|
.get_and_decode[T](
|
|
|
endpoint,
|
|
|
- params ++ Map("page" -> page, "per_page" -> per_page)
|
|
|
+ params ++ List("page" -> page, "per_page" -> per_page)
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +100,7 @@ object EndpointResponse {
|
|
|
|
|
|
def getAllData(
|
|
|
endpoint: String,
|
|
|
- params: Map[String, Any],
|
|
|
+ params: List[(String, Any)],
|
|
|
dataSoFar: ListOfGames = Nil,
|
|
|
page: Option[Int] = Some(1)
|
|
|
): ListOfGames = {
|
|
|
@@ -128,7 +128,7 @@ object EndpointResponse {
|
|
|
teams.flatMap(team => {
|
|
|
getAllData(
|
|
|
"https://www.balldontlie.io/api/v1/games",
|
|
|
- Map(
|
|
|
+ List(
|
|
|
"seasons[]" -> List(season).mkString(","),
|
|
|
"team_ids[]" -> team
|
|
|
)
|
|
|
@@ -137,11 +137,11 @@ object EndpointResponse {
|
|
|
}
|
|
|
|
|
|
def getStats(game_ids: List[Int]): ListOfStats = {
|
|
|
- implicit val gamesResponseR: Reader[StatsResponse] = macroR[StatsResponse]
|
|
|
+ implicit val statsResponseR: Reader[StatsResponse] = macroR[StatsResponse]
|
|
|
|
|
|
def getAllData(
|
|
|
endpoint: String,
|
|
|
- params: Map[String, Any],
|
|
|
+ params: List[(String, Any)],
|
|
|
dataSoFar: ListOfStats = Nil,
|
|
|
page: Option[Int] = Some(1)
|
|
|
): ListOfStats = {
|
|
|
@@ -156,6 +156,7 @@ object EndpointResponse {
|
|
|
stats_per_page,
|
|
|
params
|
|
|
)
|
|
|
+ println(response.meta)
|
|
|
getAllData(
|
|
|
endpoint,
|
|
|
params,
|
|
|
@@ -167,7 +168,7 @@ object EndpointResponse {
|
|
|
|
|
|
getAllData(
|
|
|
"https://www.balldontlie.io/api/v1/stats",
|
|
|
- Map(("game_ids" -> game_ids))
|
|
|
+ game_ids.map("game_ids[]" -> _)
|
|
|
)
|
|
|
}
|
|
|
}
|