Use a string rather than a dbref for game rematch pointer
This commit is contained in:
parent
9d887b8e2d
commit
2de1451bc9
|
@ -26,8 +26,8 @@ final class GameCleanNext(gameRepo: GameRepo) {
|
|||
)
|
||||
|
||||
for (game ← cursor) {
|
||||
game.getAs[DBRef]("next") foreach { nextRef ⇒
|
||||
if (!exists(nextRef.getId.toString)) {
|
||||
game.getAs[String]("next") foreach { nextId ⇒
|
||||
if (!exists(nextId)) {
|
||||
game.getAs[String]("_id") foreach unsetNext
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import chess.Pos.piotr
|
|||
import chess.Role.forsyth
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import com.mongodb.DBRef
|
||||
import org.scala_tools.time.Imports._
|
||||
import com.novus.salat.annotations.Key
|
||||
|
||||
|
@ -29,7 +28,7 @@ case class DbGame(
|
|||
castles: String = "KQkq",
|
||||
mode: Mode = Mode.default,
|
||||
variant: Variant = Variant.default,
|
||||
next: Option[DBRef] = None,
|
||||
next: Option[String] = None,
|
||||
lastMoveTime: Option[Int] = None,
|
||||
createdAt: Option[DateTime] = None,
|
||||
updatedAt: Option[DateTime] = None) {
|
||||
|
@ -309,8 +308,6 @@ case class DbGame(
|
|||
0
|
||||
)
|
||||
|
||||
def nextId: Option[String] = next map (_.getId.toString)
|
||||
|
||||
def deadPiecesOf(color: Color): List[Role] = toChess.deads collect {
|
||||
case (_, piece) if piece is color ⇒ piece.role
|
||||
}
|
||||
|
@ -388,7 +385,7 @@ case class RawDbGame(
|
|||
castles: String = "KQkq",
|
||||
isRated: Boolean = false,
|
||||
v: Int = 1,
|
||||
next: Option[DBRef],
|
||||
next: Option[String] = None,
|
||||
lmt: Option[Int] = None,
|
||||
createdAt: Option[DateTime],
|
||||
updatedAt: Option[DateTime]) {
|
||||
|
|
|
@ -23,7 +23,7 @@ final class Rematcher(
|
|||
attempt(fullId, {
|
||||
case pov @ Pov(game, color) if game playerCanRematch color ⇒
|
||||
success(game.opponent(color).isOfferingRematch.fold(
|
||||
game.nextId.fold(
|
||||
game.next.fold(
|
||||
rematchExists(pov),
|
||||
rematchJoin(pov)
|
||||
),
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
</div>
|
||||
<div class="lichess_separator"></div>
|
||||
@round.username(player)
|
||||
@game.nextId.map { nextId =>
|
||||
@game.next.map { next =>
|
||||
<div class="lichess_control buttons">
|
||||
<a class="button" href="@routes.Round.watcher(nextId, opponent.color.name)">View rematch</a>
|
||||
<a class="button" href="@routes.Round.watcher(next, opponent.color.name)">View rematch</a>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ function user(oid) {
|
|||
|
||||
print("Games");
|
||||
var batch = 10000;
|
||||
var max = 100000;
|
||||
var oGames = db.game;
|
||||
var nGames = db.game2;
|
||||
var it = 0, totalNb = oGames.count();
|
||||
|
@ -27,6 +26,14 @@ oGames.find().batchSize(batch).forEach(function(game) {
|
|||
game.winId = user(game.winnerUserId);
|
||||
delete game.winnerUserId;
|
||||
}
|
||||
if (game.next) {
|
||||
var next = game.next['$id'];
|
||||
if (oGames.count({_id: next}) == 1) {
|
||||
game.next = next;
|
||||
} else {
|
||||
delete game.next;
|
||||
}
|
||||
}
|
||||
if (game.userIds) {
|
||||
var userIds = [];
|
||||
game.userIds.forEach(function(oid) { userIds.push(user(oid)); });
|
||||
|
|
|
@ -4,7 +4,7 @@ var nUsers = db.user2;
|
|||
nUsers.drop();
|
||||
db.fos_user_group.drop();
|
||||
oUsers.find().forEach(function(user) {
|
||||
user.oid = user._id;
|
||||
user.oid = user._id.toString();
|
||||
user._id = user.usernameCanonical;
|
||||
if (user.elo < 800) user.elo = 800;
|
||||
delete user["usernameCanonical"];
|
||||
|
|
1
todo
1
todo
|
@ -21,7 +21,6 @@ use play-navigator router case class MyRegexStr(value: String); implicit val MyR
|
|||
http://codetunes.com/2012/05/09/scala-dsl-tutorial-writing-web-framework-router
|
||||
use POST instead of GET where it makes sense
|
||||
endgame sound http://en.lichess.org/forum/lichess-feedback/checkmate-sound-feature?page=1#1
|
||||
game.next dbref => string
|
||||
translation contributions
|
||||
|
||||
next deploy:
|
||||
|
|
Loading…
Reference in a new issue