projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improvements - untested
[vchess.git]
/
server
/
models
/
Game.js
diff --git
a/server/models/Game.js
b/server/models/Game.js
index
21ece2f
..
3fde91f
100644
(file)
--- a/
server/models/Game.js
+++ b/
server/models/Game.js
@@
-91,11
+91,18
@@
const GameModel =
db.all(query, (err2,players) => {
if (light)
{
db.all(query, (err2,players) => {
if (light)
{
- const game = Object.assign({},
- gameInfo,
- {players: players}
- );
- cb(null, game);
+ query =
+ "SELECT COUNT(*) AS nbMoves " +
+ "FROM Moves " +
+ "WHERE gid = " + id;
+ db.get(query, (err,ret) => {
+ const game = Object.assign({},
+ gameInfo,
+ {players: players},
+ {movesCount: ret.nbMoves}
+ );
+ cb(null, game);
+ });
}
else
{
}
else
{
@@
-235,7
+242,6
@@
const GameModel =
query += modifs + " WHERE id = " + id;
db.run(query);
}
query += modifs + " WHERE id = " + id;
db.run(query);
}
- let wrongMoveIndex = false;
if (obj.move)
{
// Security: only update moves if index is right
if (obj.move)
{
// Security: only update moves if index is right
@@
-263,6
+269,14
@@
const GameModel =
+ id + ",?,'" + obj.chat.name + "'," + Date.now() + ")";
db.run(query, obj.chat.msg);
}
+ id + ",?,'" + obj.chat.name + "'," + Date.now() + ")";
db.run(query, obj.chat.msg);
}
+ else if (obj.delchat)
+ {
+ query =
+ "DELETE " +
+ "FROM Chats " +
+ "WHERE gid = " + id;
+ db.run(query, cb);
+ }
});
},
});
},