Explorar el Código

Do not use writeOrReadBack function on Extract.getStats [probably useless]

theenglishway (time) hace 2 años
padre
commit
f41bc1744b
Se han modificado 1 ficheros con 9 adiciones y 5 borrados
  1. 9 5
      src/main/scala/Extract.scala

+ 9 - 5
src/main/scala/Extract.scala

@@ -45,11 +45,15 @@ object Extract {
     writeOrReadBack(output, getData)
   }
 
-  def getStats(output: os.Path, gameIds: List[Int]) = {
-    def getData() = {
-      EndpointResponse.getStats(gameIds)
-    }
+  def getStats(file: os.Path, gameIds: List[Int]) = {
+    if (!os.exists(file)) {
+      val data = EndpointResponse.getStats(gameIds)
+      Utils.writeToFile(PlayerGameStats.as_json_value(data), file)
 
-    writeOrReadBack(output, getData)
+      data
+    } else {
+      println(s"file $file already exists, reading back from it")
+      Utils.readFromFile[List[PlayerGameStats]](file)
+    }
   }
 }