projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cosmetics, mostly, and a few small bugs fixes
[vchess.git]
/
server
/
models
/
Game.js
diff --git
a/server/models/Game.js
b/server/models/Game.js
index
ee381d4
..
1d2cd68
100644
(file)
--- a/
server/models/Game.js
+++ b/
server/models/Game.js
@@
-128,12
+128,13
@@
const GameModel =
db.serialize(function() {
let query =
"SELECT id, vid, cadence, created, score, white, black " +
db.serialize(function() {
let query =
"SELECT id, vid, cadence, created, score, white, black " +
- "FROM Games ";
- if (uid > 0) query +=
- "WHERE " +
- " created < " + cursor + " AND " +
- " white <> " + uid + " AND " +
- " black <> " + uid + " ";
+ "FROM Games " +
+ "WHERE created < " + cursor + " ";
+ if (uid > 0) {
+ query +=
+ " AND white <> " + uid + " " +
+ " AND black <> " + uid + " ";
+ }
query +=
"ORDER BY created DESC " +
"LIMIT 20"; //TODO: 20 hard-coded...
query +=
"ORDER BY created DESC " +
"LIMIT 20"; //TODO: 20 hard-coded...
@@
-309,11
+310,12
@@
const GameModel =
) && (
!obj.rematchOffer || !!(obj.rematchOffer.match(/^[wbn]$/))
) && (
) && (
!obj.rematchOffer || !!(obj.rematchOffer.match(/^[wbn]$/))
) && (
- !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
+ // TODO: check if commas are still used (probably not)
+ !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9,. /-]*$/))
) && (
!obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
) && (
) && (
!obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
) && (
- !obj.chatRead ||
!(['w','b'].includes(obj.chatRead)
)
+ !obj.chatRead ||
['w','b'].includes(obj.chatRead
)
) && (
!obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
) && (
) && (
!obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
) && (
@@
-483,6
+485,7
@@
const GameModel =
)
||
(
)
||
(
+ !!movesGroups[g.id] &&
movesGroups[g.id].nbMoves == 1 &&
tsNow - movesGroups[g.id].lastMaj > 14*day
)
movesGroups[g.id].nbMoves == 1 &&
tsNow - movesGroups[g.id].lastMaj > 14*day
)