Early system refactoring

pull/1/merge
Thibault Duplessis 2012-03-01 00:19:23 +01:00
parent dbba731729
commit de6ea1eafb
6 changed files with 25 additions and 44 deletions

View File

@ -18,7 +18,7 @@ trait Dependencies {
val json = "net.liftweb" %% "lift-json" % "2.4-RC1"
val casbah = "com.mongodb.casbah" %% "casbah" % "2.1.5-1"
val salat = "com.novus" %% "salat-core" % "0.0.8-SNAPSHOT"
val slf4jNop = "org.slf4j" % "slf4j-nop" % "1.6.4"
val slf4j = "org.slf4j" % "slf4j-nop" % "1.6.4"
val instrumenter = "com.google.code.java-allocation-instrumenter" % "java-allocation-instrumenter" % "2.0"
val gson = "com.google.code.gson" % "gson" % "1.7.1"
val scalalib = "com.github.ornicar" %% "scalalib" % "1.15"
@ -45,11 +45,11 @@ object ApplicationBuild extends Build with Resolvers with Dependencies {
)
lazy val system = Project("system", file("system"), settings = buildSettings).settings(
libraryDependencies := Seq(scalalib, scalaz, config, redis, json, casbah, salat)
libraryDependencies := Seq(scalalib, scalaz, config, redis, json, casbah, salat, slf4j)
) dependsOn (chess)
lazy val http = Project("http", file("http"), settings = buildSettings).settings(
libraryDependencies := Seq(scalalib, scalaz),
libraryDependencies := Seq(scalalib, scalaz, slf4j),
resolvers := Seq(typesafe, typesafeS)
) dependsOn (system)

View File

@ -1,12 +0,0 @@
mongo {
host = 127.0.0.1
port = 27017
dbName = lichess
collection {
game = game2
}
}
redis {
host = localhost
port = 6379
}

View File

@ -17,18 +17,21 @@ trait SystemEnv {
def mongodb = MongoConnection(
config getString "mongo.host",
config getInt "mongo.port"
)(config getString "mongo.dbname")
)(config getString "mongo.dbName")
def redis = new RedisClient(
config getString "redis.host",
config getInt "redis.port")
}
trait EnvBuilder {
object SystemEnv extends EnvBuilder {
def apply(overrides: String = "") = new SystemEnv {
val config = makeConfig(overrides, "lila.conf", "system")
val config = makeConfig(overrides, "lila.conf")
}
}
trait EnvBuilder {
import java.io.File

View File

@ -5,8 +5,10 @@ import com.novus.salat.annotations._
import com.mongodb.casbah.Imports._
case class Game(
@Key("_id") id: String,
players: List[Player] = Nil
)
@Key("_id") id: String,
players: List[Player],
pgn: String,
status: Int,
turns: Int,
variant: Int) {
}

View File

@ -5,10 +5,13 @@ import com.novus.salat.annotations._
import com.mongodb.casbah.Imports._
case class Player(
id: String,
color: String,
ps: String,
aiLevel: Option[Int],
isWinner: Option[Boolean],
evts: Option[String],
elo: Option[Int]) {
id: String,
color: String,
ps: String
)
def isAi = aiLevel.isDefined
}

View File

@ -1,15 +0,0 @@
package lila.system
package repo
import model._
import com.novus.salat._
import com.novus.salat.global._
import com.novus.salat.dao._
import com.mongodb.casbah.MongoCollection
import com.mongodb.casbah.Imports._
class GameRepo(collection: MongoCollection) extends SalatDAO[Game, String](collection) {
def game(id: String): Option[Game] = findOneByID(id)
}