mirror of
https://github.com/AsgardEternal/SquadJSDocker.git
synced 2025-01-02 10:59:18 -06:00
Update db-log-addOn.js
This commit is contained in:
parent
18ddd401cb
commit
22631f081d
@ -81,24 +81,31 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async mount() {
|
async mount() {
|
||||||
|
console.log('Mounting db-log');
|
||||||
await super.mount();
|
await super.mount();
|
||||||
|
console.log('finished mounting db-log');
|
||||||
this.server.on('PLAYER_CONNECTED', this.onPlayerConnected);
|
this.server.on('PLAYER_CONNECTED', this.onPlayerConnected);
|
||||||
this.server.on('PLAYER_DISCONNECTED', this.onPlayerDisconnected);
|
this.server.on('PLAYER_DISCONNECTED', this.onPlayerDisconnected);
|
||||||
|
console.log('finished mounting db-log-addOn');
|
||||||
}
|
}
|
||||||
|
|
||||||
async repairDB() {
|
async repairDB() {
|
||||||
|
console.log('starting DB repair');
|
||||||
await super.repairDB();
|
await super.repairDB();
|
||||||
let lastTickTime = this.models.TickRate.findOne(
|
console.log('starting DB repair for addOn');
|
||||||
|
let lastTickTime = await this.models.TickRate.findOne(
|
||||||
{ where: { server: this.options.overrideServerID || this.server.id},
|
{ where: { server: this.options.overrideServerID || this.server.id},
|
||||||
order: [['id', 'DESC']]}
|
order: [['id', 'DESC']]}
|
||||||
);
|
);
|
||||||
|
console.log('last tick found:', lastTickTime);
|
||||||
let lastServerTime = lastTickTime.time;
|
let lastServerTime = lastTickTime.time;
|
||||||
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);
|
||||||
const {not} = Sequelize.Op;
|
const {not} = Sequelize.Op;
|
||||||
this.models.PlayerTime.update(
|
let rowUpdate = await this.models.PlayerTime.update(
|
||||||
{ leaveTime: lastServerTime },
|
{ leaveTime: lastServerTime },
|
||||||
{ where: {
|
{ where: {
|
||||||
leaveTime: null,
|
leaveTime: null,
|
||||||
@ -106,6 +113,8 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
[not]: [{player: playerOnlineID}]
|
[not]: [{player: playerOnlineID}]
|
||||||
} }
|
} }
|
||||||
);
|
);
|
||||||
|
console.log('updated playerTimes row count: %i', rowUpdate[0]);
|
||||||
|
console.log('finish DB repair');
|
||||||
}
|
}
|
||||||
|
|
||||||
async unmount() {
|
async unmount() {
|
||||||
|
Loading…
Reference in New Issue
Block a user