mirror of
https://github.com/AsgardEternal/DBLogExtension.git
synced 2025-01-02 13:19:19 -06:00
refactor playertimenew -> playertime
This commit is contained in:
parent
7aec03da68
commit
14720e191d
@ -37,7 +37,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
this.seeding = ServerState.init;
|
this.seeding = ServerState.init;
|
||||||
|
|
||||||
this.createModel(
|
this.createModel(
|
||||||
'PlayerTimeNew',
|
'PlayerTime',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
@ -63,12 +63,12 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.models.Server.hasMany(this.models.PlayerTimeNew, {
|
this.models.Server.hasMany(this.models.PlayerTime, {
|
||||||
foreignKey: {name: 'server', allowNull: false},
|
foreignKey: {name: 'server', allowNull: false},
|
||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.models.SteamUser.hasMany(this.models.PlayerTimeNew, {
|
this.models.SteamUser.hasMany(this.models.PlayerTime, {
|
||||||
foreignKey: {name: 'player'},
|
foreignKey: {name: 'player'},
|
||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
});
|
});
|
||||||
@ -79,7 +79,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
|
|
||||||
async prepareToMount() {
|
async prepareToMount() {
|
||||||
await super.prepareToMount();
|
await super.prepareToMount();
|
||||||
await this.models.PlayerTimeNew.sync();
|
await this.models.PlayerTime.sync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
console.log(updateVals);
|
console.log(updateVals);
|
||||||
console.log(whereStuff);
|
console.log(whereStuff);
|
||||||
|
|
||||||
const rowUpdate = await this.models.PlayerTimeNew.update(
|
const rowUpdate = await this.models.PlayerTime.update(
|
||||||
updateVals, {
|
updateVals, {
|
||||||
where: whereStuff,
|
where: whereStuff,
|
||||||
logging: console.log
|
logging: console.log
|
||||||
@ -156,7 +156,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async unmount() {
|
async unmount() {
|
||||||
this.models.PlayerTimeNew.update(
|
this.models.PlayerTime.update(
|
||||||
{leaveTime: 0},
|
{leaveTime: 0},
|
||||||
{where: {leaveTime: null, server: this.options.overrideServerID || this.server.id}}
|
{where: {leaveTime: null, server: this.options.overrideServerID || this.server.id}}
|
||||||
);
|
);
|
||||||
@ -169,7 +169,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
if(oldState === newState) return;
|
if(oldState === newState) return;
|
||||||
const timeNow = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
|
const timeNow = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
|
||||||
console.log(timeNow);
|
console.log(timeNow);
|
||||||
const curPlayer = await this.models.PlayerTimeNew.findAll({
|
const curPlayer = await this.models.PlayerTime.findAll({
|
||||||
where: {
|
where: {
|
||||||
endTime: null,
|
endTime: null,
|
||||||
serverState: oldState,
|
serverState: oldState,
|
||||||
@ -190,7 +190,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(curplayerarr);
|
console.log(curplayerarr);
|
||||||
await this.models.PlayerTimeNew.update(
|
await this.models.PlayerTime.update(
|
||||||
{ endTime: timeNow },
|
{ endTime: timeNow },
|
||||||
{
|
{
|
||||||
where: {
|
where: {
|
||||||
@ -200,7 +200,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await this.models.PlayerTimeNew.bulkCreate(curplayerarr,{
|
await this.models.PlayerTime.bulkCreate(curplayerarr,{
|
||||||
fields: ['startTime', 'endTime','serverState','session','server','player']
|
fields: ['startTime', 'endTime','serverState','session','server','player']
|
||||||
});
|
});
|
||||||
this.seeding = newState;
|
this.seeding = newState;
|
||||||
@ -250,7 +250,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
steamID: info.player.steamID,
|
steamID: info.player.steamID,
|
||||||
lastName: info.player.name
|
lastName: info.player.name
|
||||||
});
|
});
|
||||||
await this.models.PlayerTimeNew.create({
|
await this.models.PlayerTime.create({
|
||||||
server: this.options.overrideServerID || this.server.id,
|
server: this.options.overrideServerID || this.server.id,
|
||||||
player: info.steamID,
|
player: info.steamID,
|
||||||
startTime: info.time,
|
startTime: info.time,
|
||||||
@ -269,7 +269,7 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
lastName: info.player.name
|
lastName: info.player.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const rowAffect = await this.models.PlayerTimeNew.update(
|
const rowAffect = await this.models.PlayerTime.update(
|
||||||
{endTime: info.time},
|
{endTime: info.time},
|
||||||
{where:
|
{where:
|
||||||
{
|
{
|
||||||
@ -281,3 +281,4 @@ export default class DBLogPlayerTime extends DBLog {
|
|||||||
console.log('player disconnect rows update: %i', rowAffect[0]);
|
console.log('player disconnect rows update: %i', rowAffect[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Koobs
|
||||||
|
Loading…
Reference in New Issue
Block a user