projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A few small fixes + add Monster variant
[vchess.git]
/
server
/
models
/
Game.js
diff --git
a/server/models/Game.js
b/server/models/Game.js
index
5f332b7
..
aec80a0
100644
(file)
--- a/
server/models/Game.js
+++ b/
server/models/Game.js
@@
-380,7
+380,7
@@
const GameModel =
"FROM Games " +
"WHERE id = " + id;
db.get(query, (err2, ret2) => {
"FROM Games " +
"WHERE id = " + id;
db.get(query, (err2, ret2) => {
- const daysTc = parseInt(ret2.cadence.match(/
\(^[0-9]+\)
/)[0]);
+ const daysTc = parseInt(ret2.cadence.match(/
^[0-9]+
/)[0]);
if (Date.now() - ret.lastPlayed > daysTc * 24 * 3600 * 1000)
finishAndSendQuery();
else cb({ errmsg: "Time not over" });
if (Date.now() - ret.lastPlayed > daysTc * 24 * 3600 * 1000)
finishAndSendQuery();
else cb({ errmsg: "Time not over" });
@@
-454,7
+454,7
@@
const GameModel =
"SELECT gid, count(*) AS nbMoves, MAX(played) AS lastMaj " +
"FROM Moves " +
"GROUP BY gid";
"SELECT gid, count(*) AS nbMoves, MAX(played) AS lastMaj " +
"FROM Moves " +
"GROUP BY gid";
- db.
get
(query, (err2, mstats) => {
+ db.
all
(query, (err2, mstats) => {
// Reorganize moves data to avoid too many array lookups:
let movesGroups = {};
mstats.forEach(ms => {
// Reorganize moves data to avoid too many array lookups:
let movesGroups = {};
mstats.forEach(ms => {
@@
-464,18
+464,18
@@
const GameModel =
};
});
// Remove games still not really started,
};
});
// Remove games still not really started,
- // with no action in the last
3 month
s:
+ // with no action in the last
2 week
s:
let toRemove = [];
games.forEach(g => {
if (
(
!movesGroups[g.id] &&
let toRemove = [];
games.forEach(g => {
if (
(
!movesGroups[g.id] &&
- tsNow - g.created >
91
*day
+ tsNow - g.created >
14
*day
)
||
(
movesGroups[g.id].nbMoves == 1 &&
)
||
(
movesGroups[g.id].nbMoves == 1 &&
- tsNow - movesGroups[g.id].lastMaj >
91
*day
+ tsNow - movesGroups[g.id].lastMaj >
14
*day
)
) {
toRemove.push(g.id);
)
) {
toRemove.push(g.id);