Update db-log-addOn.js

This commit is contained in:
Skillet 2023-03-04 10:27:04 -05:00 committed by GitHub
parent 22631f081d
commit 29568dcb6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,19 +99,21 @@ export default class DBLogPlayerTime extends DBLog {
); );
console.log('last tick found:', lastTickTime); console.log('last tick found:', lastTickTime);
let lastServerTime = lastTickTime.time; let lastServerTime = lastTickTime.time;
console.log('last time found:', lastServerTime);
let playerOnlineID = []; let playerOnlineID = [];
for (player of this.server.players){ for (player of this.server.players){
playerOnlineID.push(player.steamID); playerOnlineID.push(player.steamID);
} }
console.log('players online:', playerOnlineID); console.log('players online:', playerOnlineID);
const {not} = Sequelize.Op; const Op = require('sequelize').Op;
let rowUpdate = await this.models.PlayerTime.update( let rowUpdate = await this.models.PlayerTime.update(
{ leaveTime: lastServerTime }, { leaveTime: lastServerTime },
{ where: { { where: {
leaveTime: null, leaveTime: null,
server: this.options.overrideServerID || this.server.id, server: this.options.overrideServerID || this.server.id,
[not]: [{player: playerOnlineID}] { [Op.ne]: { player: playerOnlineID } }
} } } }
{ logging: console.log }
); );
console.log('updated playerTimes row count: %i', rowUpdate[0]); console.log('updated playerTimes row count: %i', rowUpdate[0]);
console.log('finish DB repair'); console.log('finish DB repair');