mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +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)) {
|
if (this.lastLocation.playerList.has(D.ref.displayName)) {
|
||||||
inCurrentWorld = true;
|
inCurrentWorld = true;
|
||||||
}
|
}
|
||||||
database.getLastSeen(D.ref, inCurrentWorld).then((ref1) => {
|
database.getUserStats(D.ref, inCurrentWorld).then((ref1) => {
|
||||||
if (ref1.userId === D.id) {
|
if (ref1.userId === D.id) {
|
||||||
D.lastSeen = ref1.created_at;
|
D.lastSeen = ref1.created_at;
|
||||||
}
|
D.joinCount = ref1.joinCount;
|
||||||
});
|
D.timeSpent = ref1.timeSpent;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -16034,30 +16026,22 @@ speechSynthesis.getVoices();
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getJoinCount(ctx.ref);
|
var inCurrentWorld = false;
|
||||||
this.getLastSeen(ctx.ref);
|
if (this.lastLocation.playerList.has(ctx.ref.displayName)) {
|
||||||
this.getTimeSpent(ctx.ref);
|
inCurrentWorld = true;
|
||||||
|
}
|
||||||
|
this.getUserStats(ctx.ref);
|
||||||
ctx.ref.$friendNum = ctx.no;
|
ctx.ref.$friendNum = ctx.no;
|
||||||
results.push(ctx.ref);
|
results.push(ctx.ref);
|
||||||
}
|
}
|
||||||
this.friendsListTable.data = results;
|
this.friendsListTable.data = results;
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.getJoinCount = async function (ctx) {
|
$app.methods.getUserStats = async function (ctx) {
|
||||||
var ref = await database.getJoinCount(ctx);
|
var ref = await database.getUserStats(ctx);
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
ctx.$joinCount = ref.joinCount;
|
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;
|
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;
|
ctx.$timeSpent = ref.timeSpent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -873,6 +873,36 @@ class Database {
|
|||||||
return ref;
|
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) {
|
async lookupFeedDatabase(search, filters, vipList) {
|
||||||
var search = search.replaceAll("'", "''");
|
var search = search.replaceAll("'", "''");
|
||||||
var vipQuery = '';
|
var vipQuery = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user