mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-02 21:16:07 +02:00
Bulk add OnPlayerLeft to database when leaving instance
This commit is contained in:
+14
-9
@@ -7808,7 +7808,12 @@ speechSynthesis.getVoices();
|
|||||||
friendList: new Map()
|
friendList: new Map()
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.lastLocationReset = function () {
|
$app.methods.lastLocationReset = function (gameLogDate) {
|
||||||
|
var dateTime = gameLogDate;
|
||||||
|
if (!gameLogDate) {
|
||||||
|
dateTime = new Date().toJSON();
|
||||||
|
}
|
||||||
|
var dateTimeStamp = Date.parse(dateTime);
|
||||||
this.photonLobby = new Map();
|
this.photonLobby = new Map();
|
||||||
this.photonLobbyCurrent = new Map();
|
this.photonLobbyCurrent = new Map();
|
||||||
this.photonLobbyMaster = 0;
|
this.photonLobbyMaster = 0;
|
||||||
@@ -7827,23 +7832,23 @@ speechSynthesis.getVoices();
|
|||||||
this.photonEventTable.data = [];
|
this.photonEventTable.data = [];
|
||||||
}
|
}
|
||||||
var playerList = Array.from(this.lastLocation.playerList.values());
|
var playerList = Array.from(this.lastLocation.playerList.values());
|
||||||
|
var dataBaseEntries = [];
|
||||||
for (var ref of playerList) {
|
for (var ref of playerList) {
|
||||||
var time = new Date().getTime() - ref.joinTime;
|
|
||||||
var entry = {
|
var entry = {
|
||||||
created_at: new Date().toJSON(),
|
created_at: dateTime,
|
||||||
type: 'OnPlayerLeft',
|
type: 'OnPlayerLeft',
|
||||||
displayName: ref.displayName,
|
displayName: ref.displayName,
|
||||||
location: this.lastLocation.location,
|
location: this.lastLocation.location,
|
||||||
userId: ref.userId,
|
userId: ref.userId,
|
||||||
time
|
time: dateTimeStamp - ref.joinTime
|
||||||
};
|
};
|
||||||
database.addGamelogJoinLeaveToDatabase(entry);
|
dataBaseEntries.unshift(entry);
|
||||||
this.addGameLog(entry);
|
this.addGameLog(entry);
|
||||||
}
|
}
|
||||||
|
database.addGamelogJoinLeaveBulk(dataBaseEntries);
|
||||||
if (this.lastLocation.date !== 0) {
|
if (this.lastLocation.date !== 0) {
|
||||||
var timeLocation = new Date().getTime() - this.lastLocation.date;
|
|
||||||
var update = {
|
var update = {
|
||||||
time: timeLocation,
|
time: dateTimeStamp - this.lastLocation.date,
|
||||||
created_at: new Date(this.lastLocation.date).toJSON()
|
created_at: new Date(this.lastLocation.date).toJSON()
|
||||||
};
|
};
|
||||||
database.updateGamelogLocationTimeToDatabase(update);
|
database.updateGamelogLocationTimeToDatabase(update);
|
||||||
@@ -8114,7 +8119,7 @@ speechSynthesis.getVoices();
|
|||||||
type: 'LocationDestination',
|
type: 'LocationDestination',
|
||||||
location: gameLog.location
|
location: gameLog.location
|
||||||
});
|
});
|
||||||
this.lastLocationReset();
|
this.lastLocationReset(gameLog.dt);
|
||||||
this.lastLocation.location = 'traveling';
|
this.lastLocation.location = 'traveling';
|
||||||
this.lastLocationDestination = gameLog.location;
|
this.lastLocationDestination = gameLog.location;
|
||||||
this.lastLocationDestinationTime = Date.parse(gameLog.dt);
|
this.lastLocationDestinationTime = Date.parse(gameLog.dt);
|
||||||
@@ -8127,7 +8132,7 @@ speechSynthesis.getVoices();
|
|||||||
break;
|
break;
|
||||||
case 'location':
|
case 'location':
|
||||||
if (this.isGameRunning) {
|
if (this.isGameRunning) {
|
||||||
this.lastLocationReset();
|
this.lastLocationReset(gameLog.dt);
|
||||||
this.clearNowPlaying();
|
this.clearNowPlaying();
|
||||||
this.lastLocation = {
|
this.lastLocation = {
|
||||||
date: Date.parse(gameLog.dt),
|
date: Date.parse(gameLog.dt),
|
||||||
|
|||||||
@@ -520,6 +520,38 @@ class Database {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addGamelogJoinLeaveBulk(inputData) {
|
||||||
|
if (inputData.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var sqlValues = '';
|
||||||
|
var items = [
|
||||||
|
'created_at',
|
||||||
|
'type',
|
||||||
|
'displayName',
|
||||||
|
'location',
|
||||||
|
'userId',
|
||||||
|
'time'
|
||||||
|
];
|
||||||
|
for (var line of inputData) {
|
||||||
|
var field = {};
|
||||||
|
for (var item of items) {
|
||||||
|
if (typeof line[item] === 'string') {
|
||||||
|
field[item] = line[item].replace(/'/g, "''");
|
||||||
|
} else if (typeof line[item] === 'number') {
|
||||||
|
field[item] = line[item];
|
||||||
|
} else {
|
||||||
|
field[item] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlValues += `('${field.created_at}', '${field.type}', '${field.displayName}', '${field.location}', '${field.userId}', '${field.time}'), `;
|
||||||
|
}
|
||||||
|
sqlValues = sqlValues.slice(0, -2);
|
||||||
|
sqliteService.executeNonQuery(
|
||||||
|
`INSERT OR IGNORE INTO gamelog_join_leave (created_at, type, display_name, location, user_id, time) VALUES ${sqlValues}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
addGamelogPortalSpawnToDatabase(entry) {
|
addGamelogPortalSpawnToDatabase(entry) {
|
||||||
sqliteService.executeNonQuery(
|
sqliteService.executeNonQuery(
|
||||||
`INSERT OR IGNORE INTO gamelog_portal_spawn (created_at, display_name, location, user_id, instance_id, world_name) VALUES (@created_at, @display_name, @location, @user_id, @instance_id, @world_name)`,
|
`INSERT OR IGNORE INTO gamelog_portal_spawn (created_at, display_name, location, user_id, instance_id, world_name) VALUES (@created_at, @display_name, @location, @user_id, @instance_id, @world_name)`,
|
||||||
|
|||||||
Reference in New Issue
Block a user