mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-13 20:03:51 +02:00
Load friendsList/userDialog stats with single query
This commit is contained in:
@@ -12710,19 +12710,11 @@ speechSynthesis.getVoices();
|
||||
if (this.lastLocation.playerList.has(D.ref.displayName)) {
|
||||
inCurrentWorld = true;
|
||||
}
|
||||
database.getLastSeen(D.ref, inCurrentWorld).then((ref1) => {
|
||||
database.getUserStats(D.ref, inCurrentWorld).then((ref1) => {
|
||||
if (ref1.userId === D.id) {
|
||||
D.lastSeen = ref1.created_at;
|
||||
}
|
||||
});
|
||||
database.getJoinCount(D.ref).then((ref2) => {
|
||||
if (ref2.userId === D.id) {
|
||||
D.joinCount = ref2.joinCount;
|
||||
}
|
||||
});
|
||||
database.getTimeSpent(D.ref).then((ref3) => {
|
||||
if (ref3.userId === D.id) {
|
||||
D.timeSpent = ref3.timeSpent;
|
||||
D.joinCount = ref1.joinCount;
|
||||
D.timeSpent = ref1.timeSpent;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -16034,30 +16026,22 @@ speechSynthesis.getVoices();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.getJoinCount(ctx.ref);
|
||||
this.getLastSeen(ctx.ref);
|
||||
this.getTimeSpent(ctx.ref);
|
||||
var inCurrentWorld = false;
|
||||
if (this.lastLocation.playerList.has(ctx.ref.displayName)) {
|
||||
inCurrentWorld = true;
|
||||
}
|
||||
this.getUserStats(ctx.ref);
|
||||
ctx.ref.$friendNum = ctx.no;
|
||||
results.push(ctx.ref);
|
||||
}
|
||||
this.friendsListTable.data = results;
|
||||
};
|
||||
|
||||
$app.methods.getJoinCount = async function (ctx) {
|
||||
var ref = await database.getJoinCount(ctx);
|
||||
$app.methods.getUserStats = async function (ctx) {
|
||||
var ref = await database.getUserStats(ctx);
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
ctx.$joinCount = ref.joinCount;
|
||||
};
|
||||
|
||||
$app.methods.getLastSeen = async function (ctx) {
|
||||
var ref = await database.getLastSeen(ctx);
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
ctx.$lastSeen = ref.created_at;
|
||||
};
|
||||
|
||||
$app.methods.getTimeSpent = async function (ctx) {
|
||||
var ref = await database.getTimeSpent(ctx);
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
ctx.$timeSpent = ref.timeSpent;
|
||||
};
|
||||
|
||||
|
||||
@@ -873,6 +873,36 @@ class Database {
|
||||
return ref;
|
||||
}
|
||||
|
||||
async getUserStats(input, inCurrentWorld) {
|
||||
var i = 0;
|
||||
var instances = new Set();
|
||||
var ref = {
|
||||
timeSpent: 0,
|
||||
created_at: '',
|
||||
joinCount: 0,
|
||||
userId: input.id
|
||||
};
|
||||
await sqliteService.execute(
|
||||
(row) => {
|
||||
if (typeof row[2] === 'number') {
|
||||
ref.timeSpent += row[2];
|
||||
}
|
||||
i++;
|
||||
if (i === 1 || (inCurrentWorld && i === 2)) {
|
||||
ref.created_at = row[0];
|
||||
}
|
||||
instances.add(row[3]);
|
||||
},
|
||||
`SELECT created_at, user_id, time, location FROM gamelog_join_leave WHERE user_id = @userId OR display_name = @displayName ORDER BY id DESC`,
|
||||
{
|
||||
'@userId': input.id,
|
||||
'@displayName': input.displayName
|
||||
}
|
||||
);
|
||||
ref.joinCount = instances.size;
|
||||
return ref;
|
||||
}
|
||||
|
||||
async lookupFeedDatabase(search, filters, vipList) {
|
||||
var search = search.replaceAll("'", "''");
|
||||
var vipQuery = '';
|
||||
|
||||
Reference in New Issue
Block a user