mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-23 08:43:50 +02:00
Change current instance to use userId instead of displayName
Retroactively fix existing database entries
This commit is contained in:
@@ -566,9 +566,9 @@ speechSynthesis.getVoices();
|
|||||||
//
|
//
|
||||||
...json
|
...json
|
||||||
};
|
};
|
||||||
if ($app.lastLocation.playerList.has(json.displayName)) {
|
if ($app.lastLocation.playerList.has(json.id)) {
|
||||||
// update $location_at from instance join time
|
// update $location_at from instance join time
|
||||||
var player = $app.lastLocation.playerList.get(json.displayName);
|
var player = $app.lastLocation.playerList.get(json.id);
|
||||||
ref.$location_at = player.joinTime;
|
ref.$location_at = player.joinTime;
|
||||||
ref.$online_for = player.joinTime;
|
ref.$online_for = player.joinTime;
|
||||||
}
|
}
|
||||||
@@ -5428,17 +5428,14 @@ speechSynthesis.getVoices();
|
|||||||
joinTime: Date.parse(ctx.created_at),
|
joinTime: Date.parse(ctx.created_at),
|
||||||
lastAvatar: ''
|
lastAvatar: ''
|
||||||
};
|
};
|
||||||
this.lastLocation.playerList.set(ctx.displayName, userMap);
|
this.lastLocation.playerList.set(ctx.userId, userMap);
|
||||||
if (this.friends.has(ctx.userId)) {
|
if (this.friends.has(ctx.userId)) {
|
||||||
this.lastLocation.friendList.set(
|
this.lastLocation.friendList.set(ctx.userId, userMap);
|
||||||
ctx.displayName,
|
|
||||||
userMap
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctx.type === 'OnPlayerLeft') {
|
if (ctx.type === 'OnPlayerLeft') {
|
||||||
this.lastLocation.playerList.delete(ctx.displayName);
|
this.lastLocation.playerList.delete(ctx.userId);
|
||||||
this.lastLocation.friendList.delete(ctx.displayName);
|
this.lastLocation.friendList.delete(ctx.userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.lastLocation.playerList.forEach((ref1) => {
|
this.lastLocation.playerList.forEach((ref1) => {
|
||||||
@@ -5743,7 +5740,6 @@ speechSynthesis.getVoices();
|
|||||||
};
|
};
|
||||||
database.updateGamelogLocationTimeToDatabase(update);
|
database.updateGamelogLocationTimeToDatabase(update);
|
||||||
}
|
}
|
||||||
this.gameLogApiLoggingEnabled = false;
|
|
||||||
this.lastLocationDestination = '';
|
this.lastLocationDestination = '';
|
||||||
this.lastLocationDestinationTime = 0;
|
this.lastLocationDestinationTime = 0;
|
||||||
this.lastLocation = {
|
this.lastLocation = {
|
||||||
@@ -5779,17 +5775,7 @@ speechSynthesis.getVoices();
|
|||||||
$app.data.lastLocationDestinationTime = 0;
|
$app.data.lastLocationDestinationTime = 0;
|
||||||
|
|
||||||
$app.methods.silentSearchUser = function (displayName) {
|
$app.methods.silentSearchUser = function (displayName) {
|
||||||
var playerListRef = this.lastLocation.playerList.get(displayName);
|
console.log('Searching for userId for:', displayName);
|
||||||
if (
|
|
||||||
!this.gameLogApiLoggingEnabled ||
|
|
||||||
!playerListRef ||
|
|
||||||
playerListRef.userId
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.debugGameLog) {
|
|
||||||
console.log('Searching for userId for:', displayName);
|
|
||||||
}
|
|
||||||
var params = {
|
var params = {
|
||||||
n: 5,
|
n: 5,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -9318,7 +9304,7 @@ speechSynthesis.getVoices();
|
|||||||
API.getUser(args.params);
|
API.getUser(args.params);
|
||||||
}
|
}
|
||||||
var inCurrentWorld = false;
|
var inCurrentWorld = false;
|
||||||
if (this.lastLocation.playerList.has(D.ref.displayName)) {
|
if (this.lastLocation.playerList.has(D.ref.id)) {
|
||||||
inCurrentWorld = true;
|
inCurrentWorld = true;
|
||||||
}
|
}
|
||||||
if (userId !== API.currentUser.id) {
|
if (userId !== API.currentUser.id) {
|
||||||
@@ -9450,7 +9436,7 @@ speechSynthesis.getVoices();
|
|||||||
for (var friend of friendsInInstance.values()) {
|
for (var friend of friendsInInstance.values()) {
|
||||||
// if friend isn't in instance add them
|
// if friend isn't in instance add them
|
||||||
var addUser = !users.some(function (user) {
|
var addUser = !users.some(function (user) {
|
||||||
return friend.displayName === user.displayName;
|
return friend.userId === user.id;
|
||||||
});
|
});
|
||||||
if (addUser) {
|
if (addUser) {
|
||||||
var ref = API.cachedUsers.get(friend.userId);
|
var ref = API.cachedUsers.get(friend.userId);
|
||||||
@@ -9538,26 +9524,11 @@ speechSynthesis.getVoices();
|
|||||||
|
|
||||||
API.$on('USER:APPLY', function (ref) {
|
API.$on('USER:APPLY', function (ref) {
|
||||||
// add user ref to playerList, friendList, photonLobby, photonLobbyCurrent
|
// add user ref to playerList, friendList, photonLobby, photonLobbyCurrent
|
||||||
if ($app.lastLocation.playerList.has(ref.displayName)) {
|
var playerListRef = $app.lastLocation.playerList.get(ref.id);
|
||||||
var playerListRef = $app.lastLocation.playerList.get(
|
if (playerListRef) {
|
||||||
ref.displayName
|
|
||||||
);
|
|
||||||
if (!playerListRef.userId) {
|
|
||||||
playerListRef.userId = ref.id;
|
|
||||||
$app.lastLocation.playerList.set(
|
|
||||||
ref.displayName,
|
|
||||||
playerListRef
|
|
||||||
);
|
|
||||||
if ($app.lastLocation.friendList.has(ref.displayName)) {
|
|
||||||
$app.lastLocation.friendList.set(
|
|
||||||
ref.displayName,
|
|
||||||
playerListRef
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add/remove friends from lastLocation.friendList
|
// add/remove friends from lastLocation.friendList
|
||||||
if (
|
if (
|
||||||
!$app.lastLocation.friendList.has(ref.displayName) &&
|
!$app.lastLocation.friendList.has(ref.id) &&
|
||||||
$app.friends.has(ref.id)
|
$app.friends.has(ref.id)
|
||||||
) {
|
) {
|
||||||
var userMap = {
|
var userMap = {
|
||||||
@@ -9565,13 +9536,13 @@ speechSynthesis.getVoices();
|
|||||||
userId: ref.id,
|
userId: ref.id,
|
||||||
joinTime: playerListRef.joinTime
|
joinTime: playerListRef.joinTime
|
||||||
};
|
};
|
||||||
$app.lastLocation.friendList.set(ref.displayName, userMap);
|
$app.lastLocation.friendList.set(ref.id, userMap);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
$app.lastLocation.friendList.has(ref.displayName) &&
|
$app.lastLocation.friendList.has(ref.id) &&
|
||||||
!$app.friends.has(ref.id)
|
!$app.friends.has(ref.id)
|
||||||
) {
|
) {
|
||||||
$app.lastLocation.friendList.delete(ref.displayName);
|
$app.lastLocation.friendList.delete(ref.id);
|
||||||
}
|
}
|
||||||
$app.photonLobby.forEach((ref1, id) => {
|
$app.photonLobby.forEach((ref1, id) => {
|
||||||
if (
|
if (
|
||||||
@@ -9699,10 +9670,7 @@ speechSynthesis.getVoices();
|
|||||||
var playersInInstance = this.lastLocation.playerList;
|
var playersInInstance = this.lastLocation.playerList;
|
||||||
if (playersInInstance.size > 0) {
|
if (playersInInstance.size > 0) {
|
||||||
var ref = API.cachedUsers.get(API.currentUser.id);
|
var ref = API.cachedUsers.get(API.currentUser.id);
|
||||||
if (
|
if (typeof ref !== 'undefined' && playersInInstance.has(ref.id)) {
|
||||||
typeof ref !== 'undefined' &&
|
|
||||||
playersInInstance.has(ref.displayName)
|
|
||||||
) {
|
|
||||||
pushUser(ref);
|
pushUser(ref);
|
||||||
}
|
}
|
||||||
for (var player of playersInInstance.values()) {
|
for (var player of playersInInstance.values()) {
|
||||||
@@ -9719,7 +9687,7 @@ speechSynthesis.getVoices();
|
|||||||
pushUser(ref);
|
pushUser(ref);
|
||||||
} else {
|
} else {
|
||||||
var { joinTime } = this.lastLocation.playerList.get(
|
var { joinTime } = this.lastLocation.playerList.get(
|
||||||
player.displayName
|
player.userId
|
||||||
);
|
);
|
||||||
if (!joinTime) {
|
if (!joinTime) {
|
||||||
joinTime = Date.now();
|
joinTime = Date.now();
|
||||||
@@ -10801,7 +10769,7 @@ speechSynthesis.getVoices();
|
|||||||
for (var friend of friendsInInstance.values()) {
|
for (var friend of friendsInInstance.values()) {
|
||||||
// if friend isn't in instance add them
|
// if friend isn't in instance add them
|
||||||
var addUser = !instance.users.some(function (user) {
|
var addUser = !instance.users.some(function (user) {
|
||||||
return friend.displayName === user.displayName;
|
return friend.userId === user.id;
|
||||||
});
|
});
|
||||||
if (addUser) {
|
if (addUser) {
|
||||||
var ref = API.cachedUsers.get(friend.userId);
|
var ref = API.cachedUsers.get(friend.userId);
|
||||||
@@ -10984,7 +10952,7 @@ speechSynthesis.getVoices();
|
|||||||
for (var friend of friendsInInstance.values()) {
|
for (var friend of friendsInInstance.values()) {
|
||||||
// if friend isn't in instance add them
|
// if friend isn't in instance add them
|
||||||
var addUser = !instance.users.some(function (user) {
|
var addUser = !instance.users.some(function (user) {
|
||||||
return friend.displayName === user.displayName;
|
return friend.userId === user.id;
|
||||||
});
|
});
|
||||||
if (addUser) {
|
if (addUser) {
|
||||||
var ref = API.cachedUsers.get(friend.userId);
|
var ref = API.cachedUsers.get(friend.userId);
|
||||||
@@ -17497,7 +17465,7 @@ speechSynthesis.getVoices();
|
|||||||
API.cachedUsers.forEach((ref, id) => {
|
API.cachedUsers.forEach((ref, id) => {
|
||||||
if (
|
if (
|
||||||
!this.friends.has(id) &&
|
!this.friends.has(id) &&
|
||||||
!this.lastLocation.playerList.has(ref.displayName) &&
|
!this.lastLocation.playerList.has(ref.id) &&
|
||||||
id !== API.currentUser.id
|
id !== API.currentUser.id
|
||||||
) {
|
) {
|
||||||
API.cachedUsers.delete(id);
|
API.cachedUsers.delete(id);
|
||||||
@@ -18359,7 +18327,7 @@ speechSynthesis.getVoices();
|
|||||||
!this.lastLocation.location ||
|
!this.lastLocation.location ||
|
||||||
this.lastLocation.location !== ref.travelingToLocation ||
|
this.lastLocation.location !== ref.travelingToLocation ||
|
||||||
ref.id === API.currentUser.id ||
|
ref.id === API.currentUser.id ||
|
||||||
this.lastLocation.playerList.has(ref.displayName)
|
this.lastLocation.playerList.has(ref.id)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -18518,7 +18486,7 @@ speechSynthesis.getVoices();
|
|||||||
);
|
);
|
||||||
|
|
||||||
$app.methods.updateDatabaseVersion = async function () {
|
$app.methods.updateDatabaseVersion = async function () {
|
||||||
var databaseVersion = 9;
|
var databaseVersion = 10;
|
||||||
if (this.databaseVersion < databaseVersion) {
|
if (this.databaseVersion < databaseVersion) {
|
||||||
if (this.databaseVersion) {
|
if (this.databaseVersion) {
|
||||||
var msgBox = this.$message({
|
var msgBox = this.$message({
|
||||||
@@ -18541,6 +18509,7 @@ speechSynthesis.getVoices();
|
|||||||
await database.fixBrokenNotifications(); // fix notifications being null
|
await database.fixBrokenNotifications(); // fix notifications being null
|
||||||
await database.fixBrokenGroupChange(); // fix spam group left & name change
|
await database.fixBrokenGroupChange(); // fix spam group left & name change
|
||||||
await database.fixCancelFriendRequestTypo(); // fix CancelFriendRequst typo
|
await database.fixCancelFriendRequestTypo(); // fix CancelFriendRequst typo
|
||||||
|
await database.fixBrokenGameLogDisplayNames(); // fix gameLog display names "DisplayName (userId)"
|
||||||
await database.vacuum(); // succ
|
await database.vacuum(); // succ
|
||||||
await configRepository.setInt(
|
await configRepository.setInt(
|
||||||
'VRCX_databaseVersion',
|
'VRCX_databaseVersion',
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default class extends baseClass {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
gameLogSessionTable: [],
|
gameLogSessionTable: [],
|
||||||
gameLogApiLoggingEnabled: false,
|
|
||||||
lastVideoUrl: '',
|
lastVideoUrl: '',
|
||||||
lastResourceloadUrl: ''
|
lastResourceloadUrl: ''
|
||||||
};
|
};
|
||||||
@@ -121,62 +120,30 @@ export default class extends baseClass {
|
|||||||
joinTime,
|
joinTime,
|
||||||
lastAvatar: ''
|
lastAvatar: ''
|
||||||
};
|
};
|
||||||
this.lastLocation.playerList.set(
|
this.lastLocation.playerList.set(userId, userMap);
|
||||||
gameLog.displayName,
|
var ref = API.cachedUsers.get(userId);
|
||||||
userMap
|
if (!userId) {
|
||||||
);
|
console.error('Missing userId:', gameLog.displayName);
|
||||||
if (userId) {
|
} else if (userId === API.currentUser.id) {
|
||||||
var ref = API.cachedUsers.get(userId);
|
// skip
|
||||||
if (userId === API.currentUser.id) {
|
} else if (this.friends.has(userId)) {
|
||||||
// skip
|
this.lastLocation.friendList.set(userId, userMap);
|
||||||
} else if (this.friends.has(userId)) {
|
if (
|
||||||
this.lastLocation.friendList.set(
|
ref.location !== this.lastLocation.location &&
|
||||||
gameLog.displayName,
|
ref.travelingToLocation !==
|
||||||
userMap
|
this.lastLocation.location
|
||||||
);
|
) {
|
||||||
if (
|
// fix $location_at with private
|
||||||
ref.location !== this.lastLocation.location &&
|
|
||||||
ref.travelingToLocation !==
|
|
||||||
this.lastLocation.location
|
|
||||||
) {
|
|
||||||
// fix $location_at with private
|
|
||||||
ref.$location_at = joinTime;
|
|
||||||
}
|
|
||||||
} else if (typeof ref !== 'undefined') {
|
|
||||||
// set $location_at to join time if user isn't a friend
|
|
||||||
ref.$location_at = joinTime;
|
ref.$location_at = joinTime;
|
||||||
} else {
|
|
||||||
if (this.debugGameLog || this.debugWebRequests) {
|
|
||||||
console.log(
|
|
||||||
'Fetching user from gameLog:',
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
API.getUser({ userId });
|
|
||||||
}
|
}
|
||||||
|
} else if (typeof ref !== 'undefined') {
|
||||||
|
// set $location_at to join time if user isn't a friend
|
||||||
|
ref.$location_at = joinTime;
|
||||||
} else {
|
} else {
|
||||||
// TODO: remove this
|
if (this.debugGameLog || this.debugWebRequests) {
|
||||||
// try fetch userId from previous encounter using database
|
console.log('Fetching user from gameLog:', userId);
|
||||||
database
|
}
|
||||||
.getUserIdFromDisplayName(gameLog.displayName)
|
API.getUser({ userId });
|
||||||
.then((oldUserId) => {
|
|
||||||
if (this.isGameRunning) {
|
|
||||||
if (oldUserId) {
|
|
||||||
API.getUser({ userId: oldUserId });
|
|
||||||
} else if (
|
|
||||||
Date.now() - joinTime <
|
|
||||||
5 * 1000
|
|
||||||
) {
|
|
||||||
workerTimers.setTimeout(
|
|
||||||
() =>
|
|
||||||
this.silentSearchUser(
|
|
||||||
gameLog.displayName
|
|
||||||
),
|
|
||||||
10 * 1000
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
this.updateVRLastLocation();
|
this.updateVRLastLocation();
|
||||||
this.getCurrentInstanceUserList();
|
this.getCurrentInstanceUserList();
|
||||||
@@ -191,15 +158,13 @@ export default class extends baseClass {
|
|||||||
database.addGamelogJoinLeaveToDatabase(entry);
|
database.addGamelogJoinLeaveToDatabase(entry);
|
||||||
break;
|
break;
|
||||||
case 'player-left':
|
case 'player-left':
|
||||||
var ref = this.lastLocation.playerList.get(
|
var ref = this.lastLocation.playerList.get(userId);
|
||||||
gameLog.displayName
|
|
||||||
);
|
|
||||||
if (typeof ref === 'undefined') {
|
if (typeof ref === 'undefined') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var time = Date.now() - ref.joinTime;
|
var time = Date.now() - ref.joinTime;
|
||||||
this.lastLocation.playerList.delete(gameLog.displayName);
|
this.lastLocation.playerList.delete(userId);
|
||||||
this.lastLocation.friendList.delete(gameLog.displayName);
|
this.lastLocation.friendList.delete(userId);
|
||||||
this.photonLobbyAvatars.delete(userId);
|
this.photonLobbyAvatars.delete(userId);
|
||||||
this.updateVRLastLocation();
|
this.updateVRLastLocation();
|
||||||
this.getCurrentInstanceUserList();
|
this.getCurrentInstanceUserList();
|
||||||
@@ -276,47 +241,25 @@ export default class extends baseClass {
|
|||||||
this.processScreenshot(gameLog.screenshotPath);
|
this.processScreenshot(gameLog.screenshotPath);
|
||||||
break;
|
break;
|
||||||
case 'api-request':
|
case 'api-request':
|
||||||
var bias = Date.parse(gameLog.dt) + 60 * 1000;
|
// var userId = '';
|
||||||
if (
|
// try {
|
||||||
!this.isGameRunning ||
|
// var url = new URL(gameLog.url);
|
||||||
this.lastLocation.location === '' ||
|
// var urlParams = new URLSearchParams(gameLog.url);
|
||||||
this.lastLocation.location === 'traveling' ||
|
// if (url.pathname.substring(0, 13) === '/api/1/users/') {
|
||||||
bias < Date.now()
|
// var pathArray = url.pathname.split('/');
|
||||||
) {
|
// userId = pathArray[4];
|
||||||
break;
|
// } else if (urlParams.has('userId')) {
|
||||||
}
|
// userId = urlParams.get('userId');
|
||||||
var userId = '';
|
// }
|
||||||
try {
|
// } catch (err) {
|
||||||
var url = new URL(gameLog.url);
|
// console.error(err);
|
||||||
var urlParams = new URLSearchParams(gameLog.url);
|
// }
|
||||||
if (url.pathname.substring(0, 13) === '/api/1/users/') {
|
// if (!userId) {
|
||||||
var pathArray = url.pathname.split('/');
|
// break;
|
||||||
userId = pathArray[4];
|
// }
|
||||||
} else if (urlParams.has('userId')) {
|
|
||||||
userId = urlParams.get('userId');
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
if (!userId) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.gameLogApiLoggingEnabled = true;
|
|
||||||
if (
|
|
||||||
API.cachedUsers.has(userId) ||
|
|
||||||
API.cachedPlayerModerationsUserIds.has(userId)
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (this.debugGameLog || this.debugWebRequests) {
|
|
||||||
console.log('Fetching user from gameLog:', userId);
|
|
||||||
}
|
|
||||||
API.getUser({ userId });
|
|
||||||
break;
|
break;
|
||||||
case 'avatar-change':
|
case 'avatar-change':
|
||||||
var ref = this.lastLocation.playerList.get(
|
var ref = this.lastLocation.playerList.get(userId);
|
||||||
gameLog.displayName
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
this.photonLoggingEnabled ||
|
this.photonLoggingEnabled ||
|
||||||
typeof ref === 'undefined' ||
|
typeof ref === 'undefined' ||
|
||||||
@@ -326,14 +269,11 @@ export default class extends baseClass {
|
|||||||
}
|
}
|
||||||
if (!ref.lastAvatar) {
|
if (!ref.lastAvatar) {
|
||||||
ref.lastAvatar = gameLog.avatarName;
|
ref.lastAvatar = gameLog.avatarName;
|
||||||
this.lastLocation.playerList.set(
|
this.lastLocation.playerList.set(userId, ref);
|
||||||
gameLog.displayName,
|
|
||||||
ref
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ref.lastAvatar = gameLog.avatarName;
|
ref.lastAvatar = gameLog.avatarName;
|
||||||
this.lastLocation.playerList.set(gameLog.displayName, ref);
|
this.lastLocation.playerList.set(userId, ref);
|
||||||
var entry = {
|
var entry = {
|
||||||
created_at: gameLog.dt,
|
created_at: gameLog.dt,
|
||||||
type: 'AvatarChange',
|
type: 'AvatarChange',
|
||||||
|
|||||||
@@ -1151,10 +1151,10 @@ export default class extends baseClass {
|
|||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
!ref.isFriend &&
|
!ref.isFriend &&
|
||||||
this.lastLocation.playerList.has(ref.displayName)
|
this.lastLocation.playerList.has(user.id)
|
||||||
) {
|
) {
|
||||||
var { joinTime } = this.lastLocation.playerList.get(
|
var { joinTime } = this.lastLocation.playerList.get(
|
||||||
ref.displayName
|
user.id
|
||||||
);
|
);
|
||||||
if (!joinTime) {
|
if (!joinTime) {
|
||||||
joinTime = Date.parse(gameLogDate);
|
joinTime = Date.parse(gameLogDate);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export default class extends baseClass {
|
|||||||
(this.sharedFeedFilters.wrist.OnPlayerJoining ===
|
(this.sharedFeedFilters.wrist.OnPlayerJoining ===
|
||||||
'VIP' &&
|
'VIP' &&
|
||||||
isFavorite)) &&
|
isFavorite)) &&
|
||||||
!$app.lastLocation.playerList.has(ref.displayName)
|
!$app.lastLocation.playerList.has(ref.id)
|
||||||
) {
|
) {
|
||||||
if (ref.$location.tag === $app.lastLocation.location) {
|
if (ref.$location.tag === $app.lastLocation.location) {
|
||||||
var feedEntry = {
|
var feedEntry = {
|
||||||
|
|||||||
@@ -2616,6 +2616,31 @@ class Database {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBrokenGameLogDisplayNames() {
|
||||||
|
var badEntries = [];
|
||||||
|
await sqliteService.execute((dbRow) => {
|
||||||
|
badEntries.push({
|
||||||
|
id: dbRow[0],
|
||||||
|
displayName: dbRow[1]
|
||||||
|
});
|
||||||
|
}, 'SELECT id, display_name FROM gamelog_join_leave WHERE display_name LIKE "% (%"');
|
||||||
|
return badEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fixBrokenGameLogDisplayNames() {
|
||||||
|
var badEntries = await this.getBrokenGameLogDisplayNames();
|
||||||
|
badEntries.forEach((entry) => {
|
||||||
|
var newDisplayName = entry.displayName.split(' (')[0];
|
||||||
|
sqliteService.executeNonQuery(
|
||||||
|
`UPDATE gamelog_join_leave SET display_name = @new_display_name WHERE id = @id`,
|
||||||
|
{
|
||||||
|
'@new_display_name': newDisplayName,
|
||||||
|
'@id': entry.id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async vacuum() {
|
async vacuum() {
|
||||||
await sqliteService.executeNonQuery('VACUUM');
|
await sqliteService.executeNonQuery('VACUUM');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user