mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 06:13:52 +02:00
Bulk add OnPlayerLeft to database when leaving instance
This commit is contained in:
@@ -7808,7 +7808,12 @@ speechSynthesis.getVoices();
|
||||
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.photonLobbyCurrent = new Map();
|
||||
this.photonLobbyMaster = 0;
|
||||
@@ -7827,23 +7832,23 @@ speechSynthesis.getVoices();
|
||||
this.photonEventTable.data = [];
|
||||
}
|
||||
var playerList = Array.from(this.lastLocation.playerList.values());
|
||||
var dataBaseEntries = [];
|
||||
for (var ref of playerList) {
|
||||
var time = new Date().getTime() - ref.joinTime;
|
||||
var entry = {
|
||||
created_at: new Date().toJSON(),
|
||||
created_at: dateTime,
|
||||
type: 'OnPlayerLeft',
|
||||
displayName: ref.displayName,
|
||||
location: this.lastLocation.location,
|
||||
userId: ref.userId,
|
||||
time
|
||||
time: dateTimeStamp - ref.joinTime
|
||||
};
|
||||
database.addGamelogJoinLeaveToDatabase(entry);
|
||||
dataBaseEntries.unshift(entry);
|
||||
this.addGameLog(entry);
|
||||
}
|
||||
database.addGamelogJoinLeaveBulk(dataBaseEntries);
|
||||
if (this.lastLocation.date !== 0) {
|
||||
var timeLocation = new Date().getTime() - this.lastLocation.date;
|
||||
var update = {
|
||||
time: timeLocation,
|
||||
time: dateTimeStamp - this.lastLocation.date,
|
||||
created_at: new Date(this.lastLocation.date).toJSON()
|
||||
};
|
||||
database.updateGamelogLocationTimeToDatabase(update);
|
||||
@@ -8114,7 +8119,7 @@ speechSynthesis.getVoices();
|
||||
type: 'LocationDestination',
|
||||
location: gameLog.location
|
||||
});
|
||||
this.lastLocationReset();
|
||||
this.lastLocationReset(gameLog.dt);
|
||||
this.lastLocation.location = 'traveling';
|
||||
this.lastLocationDestination = gameLog.location;
|
||||
this.lastLocationDestinationTime = Date.parse(gameLog.dt);
|
||||
@@ -8127,7 +8132,7 @@ speechSynthesis.getVoices();
|
||||
break;
|
||||
case 'location':
|
||||
if (this.isGameRunning) {
|
||||
this.lastLocationReset();
|
||||
this.lastLocationReset(gameLog.dt);
|
||||
this.clearNowPlaying();
|
||||
this.lastLocation = {
|
||||
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) {
|
||||
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)`,
|
||||
|
||||
Reference in New Issue
Block a user