Skip to content

Commit

Permalink
implement pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DonatJR committed Nov 4, 2018
1 parent 9a37a83 commit 4c933ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/de/htwg/se/sudoku/SudokuModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MongoDBModule extends AbstractModule with ScalaModule {

val defaultSize: Int = 9
val defaultHostname: String = "localhost"
val defaultFilePort: Int = 27017
val defaultMongoDBPort: Int = 27017

override def configure(): Unit = {
bindConstant().annotatedWith(Names.named("DefaultSize")).to(defaultSize)
Expand All @@ -64,7 +64,7 @@ class MongoDBModule extends AbstractModule with ScalaModule {
bind[GridInterface].annotatedWithName("normal").toInstance(new Grid(9))

bindConstant().annotatedWith(Names.named("MongoDBHost")).to(defaultHostname)
bindConstant().annotatedWith(Names.named("MongoDBPort")).to(defaultFilePort)
bindConstant().annotatedWith(Names.named("MongoDBPort")).to(defaultMongoDBPort)

bind[FileIOInterface].to[fileIoMongoDBImpl.FileIO]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class FileIO @Inject()(@Named("MongoDBHost") host: String, @Named("MongoDBPort")
private val collection = db.getCollection("sudoku-in-scala-col")

override def load: Try[Option[GridInterface]] = {
val resF = collection.find().projection(Projections.excludeId()).toFuture()
val res = Await.result(resF, Duration.Inf)
val resultFuture = collection.find().projection(Projections.excludeId()).toFuture()
val result = Await.result(resultFuture, Duration.Inf)

var gridOption: Option[GridInterface] = None

Try {
val json: JsValue = Json.parse(res.head.toJson())
val json: JsValue = Json.parse(result.head.toJson())
val size = (json \ "grid" \ "size").get.toString.toInt
val injector = Guice.createInjector(new SudokuModule)

Expand Down Expand Up @@ -69,8 +69,8 @@ class FileIO @Inject()(@Named("MongoDBHost") host: String, @Named("MongoDBPort")
Try {
Await.result(collection.drop().toFuture(), Duration.Inf)
val gameStateDoc = Document.apply(gridToJson(grid).toString())
val resF = collection.insertOne(gameStateDoc).toFuture()
Await.result(resF, Duration.Inf)
val resultFuture = collection.insertOne(gameStateDoc).toFuture()
Await.result(resultFuture, Duration.Inf)
}
}

Expand Down

0 comments on commit 4c933ce

Please sign in to comment.