Skip to content

Commit

Permalink
fix getting the name from the system json
Browse files Browse the repository at this point in the history
  • Loading branch information
ColaColin committed Mar 23, 2015
1 parent 0c1c17b commit e2e331f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@ object InitialReportUpdater {
private class DbLayer(dbX: DSLContext) extends InitialReportDbLayer with GenerateNewPlayer with Loggable {
def db = dbX

private def saveGetPlanetName(jsonString: String): String = try {
(for { JString(n) <- parse(jsonString) \ "name" } yield n).mkString
} catch {
case e: Exception => e.printStackTrace(); "Error determining name"
}

def insertNewPlanet(planet: ReportedPlanet): Int = {
import _root_.scala.language.implicitConversions
implicit def s2B(s: String) = try { new java.math.BigDecimal(s) } catch { case e: Exception => java.math.BigDecimal.ZERO }

db.insertInto(planets, planets.PLANET, planets.NAME).values(planet.json,
compact(render(parse(planet.json) \ "name"))).returning().fetchOne().getId()
saveGetPlanetName(planet.json)).returning().fetchOne().getId()
}

def insertNewGame(ident: String, paVersion: String, startDate: Timestamp, reportDate: Timestamp, planetId: Int, isAutomatch: Boolean): Int = {
Expand Down

0 comments on commit e2e331f

Please sign in to comment.