mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
improve gamelog sql
This commit is contained in:
@@ -663,24 +663,31 @@ const gameLog = {
|
||||
return gamelogDatabase;
|
||||
},
|
||||
|
||||
/**
|
||||
* Lookup the game log database for a specific search term
|
||||
* @param {string} search The search term
|
||||
* @param {Array} filters The filters to apply
|
||||
* @param {Array} [vipList] The list of VIP users
|
||||
* @returns {Promise<any[]>} The game log data
|
||||
*/
|
||||
|
||||
async lookupGameLogDatabase(
|
||||
search,
|
||||
filters,
|
||||
vipList,
|
||||
maxEntries = dbVars.maxTableSize
|
||||
) {
|
||||
search = search.replaceAll("'", "''");
|
||||
if (search.startsWith('wrld_') || search.startsWith('grp_')) {
|
||||
return this.getGameLogByLocation(search, filters);
|
||||
}
|
||||
const baseColumns = [
|
||||
'id',
|
||||
'created_at',
|
||||
'type',
|
||||
'display_name',
|
||||
'location',
|
||||
'user_id',
|
||||
'time',
|
||||
'world_id',
|
||||
'world_name',
|
||||
'group_name',
|
||||
'instance_id',
|
||||
'video_url',
|
||||
'video_name',
|
||||
'video_id',
|
||||
'resource_url',
|
||||
'resource_type',
|
||||
'data',
|
||||
'message'
|
||||
].join(', ');
|
||||
let vipQuery = '';
|
||||
if (vipList.length > 0) {
|
||||
vipQuery = 'AND user_id IN (';
|
||||
@@ -692,15 +699,15 @@ const gameLog = {
|
||||
}
|
||||
vipQuery += ')';
|
||||
}
|
||||
var location = true;
|
||||
var onplayerjoined = true;
|
||||
var onplayerleft = true;
|
||||
var portalspawn = true;
|
||||
var msgevent = true;
|
||||
var external = true;
|
||||
var videoplay = true;
|
||||
var resourceload_string = true;
|
||||
var resourceload_image = true;
|
||||
let location = true;
|
||||
let onplayerjoined = true;
|
||||
let onplayerleft = true;
|
||||
let portalspawn = true;
|
||||
let msgevent = true;
|
||||
let external = true;
|
||||
let videoplay = true;
|
||||
let resourceload_string = true;
|
||||
let resourceload_image = true;
|
||||
if (filters.length > 0) {
|
||||
location = false;
|
||||
onplayerjoined = false;
|
||||
@@ -743,24 +750,14 @@ const gameLog = {
|
||||
}
|
||||
});
|
||||
}
|
||||
var gamelogDatabase = [];
|
||||
const selects = [];
|
||||
if (location) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'Location',
|
||||
location: dbRow[2],
|
||||
worldId: dbRow[3],
|
||||
worldName: dbRow[4],
|
||||
time: dbRow[5],
|
||||
groupName: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' OR group_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'Location' AS type, NULL AS display_name, location, NULL AS user_id, time, world_id, world_name, group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_location ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (onplayerjoined || onplayerleft) {
|
||||
var query = '';
|
||||
let query = '';
|
||||
if (!onplayerjoined || !onplayerleft) {
|
||||
if (onplayerjoined) {
|
||||
query = "AND type = 'OnPlayerJoined'";
|
||||
@@ -768,110 +765,331 @@ const gameLog = {
|
||||
query = "AND type = 'OnPlayerLeft'";
|
||||
}
|
||||
}
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
location: dbRow[4],
|
||||
userId: dbRow[5],
|
||||
time: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_join_leave WHERE (display_name LIKE '%${search}%' AND user_id != '${dbVars.userId}') ${vipQuery} ${query} ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, type, display_name, location, user_id, time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_join_leave WHERE 1=1 ${vipQuery} ${query} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (portalspawn) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'PortalSpawn',
|
||||
displayName: dbRow[2],
|
||||
location: dbRow[3],
|
||||
userId: dbRow[4],
|
||||
instanceId: dbRow[5],
|
||||
worldName: dbRow[6]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_portal_spawn WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'PortalSpawn' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, world_name, NULL AS group_name, instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_portal_spawn WHERE 1=1 ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (msgevent) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'Event',
|
||||
data: dbRow[2]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_event WHERE data LIKE '%${search}%' ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'Event' AS type, NULL AS display_name, NULL AS location, NULL AS user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, data, NULL AS message FROM gamelog_event ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (external) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'External',
|
||||
message: dbRow[2],
|
||||
displayName: dbRow[3],
|
||||
userId: dbRow[4],
|
||||
location: dbRow[5]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_external WHERE (display_name LIKE '%${search}%' OR message LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'External' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, message FROM gamelog_external WHERE 1=1 ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (videoplay) {
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: 'VideoPlay',
|
||||
videoUrl: dbRow[2],
|
||||
videoName: dbRow[3],
|
||||
videoId: dbRow[4],
|
||||
location: dbRow[5],
|
||||
displayName: dbRow[6],
|
||||
userId: dbRow[7]
|
||||
};
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_video_play WHERE (video_url LIKE '%${search}%' OR video_name LIKE '%${search}%' OR display_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'VideoPlay' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, video_url, video_name, video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_video_play WHERE 1=1 ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (resourceload_string || resourceload_image) {
|
||||
var checkString = '';
|
||||
var checkImage = '';
|
||||
let checkString = '';
|
||||
let checkImage = '';
|
||||
if (!resourceload_string) {
|
||||
checkString = `AND resource_type != 'StringLoad'`;
|
||||
}
|
||||
if (!resourceload_image) {
|
||||
checkString = `AND resource_type != 'ImageLoad'`;
|
||||
}
|
||||
await sqliteService.execute((dbRow) => {
|
||||
var row = {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, resource_type AS type, NULL AS display_name, location, NULL AS user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, resource_url, resource_type, NULL AS data, NULL AS message FROM gamelog_resource_load WHERE 1=1 ${checkString} ${checkImage} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (selects.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const gamelogDatabase = [];
|
||||
const args = {
|
||||
'@limit': maxEntries,
|
||||
'@perTable': maxEntries
|
||||
};
|
||||
await sqliteService.execute(
|
||||
(dbRow) => {
|
||||
const row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type: dbRow[3],
|
||||
resourceUrl: dbRow[2],
|
||||
location: dbRow[4]
|
||||
type: dbRow[2]
|
||||
};
|
||||
switch (dbRow[2]) {
|
||||
case 'Location':
|
||||
row.location = dbRow[4];
|
||||
row.worldId = dbRow[7];
|
||||
row.worldName = dbRow[8];
|
||||
row.time = dbRow[6];
|
||||
row.groupName = dbRow[9];
|
||||
break;
|
||||
case 'OnPlayerJoined':
|
||||
case 'OnPlayerLeft':
|
||||
row.displayName = dbRow[3];
|
||||
row.location = dbRow[4];
|
||||
row.userId = dbRow[5];
|
||||
row.time = dbRow[6];
|
||||
break;
|
||||
case 'PortalSpawn':
|
||||
row.displayName = dbRow[3];
|
||||
row.location = dbRow[4];
|
||||
row.userId = dbRow[5];
|
||||
row.instanceId = dbRow[10];
|
||||
row.worldName = dbRow[8];
|
||||
break;
|
||||
case 'VideoPlay':
|
||||
row.videoUrl = dbRow[11];
|
||||
row.videoName = dbRow[12];
|
||||
row.videoId = dbRow[13];
|
||||
row.location = dbRow[4];
|
||||
row.displayName = dbRow[3];
|
||||
row.userId = dbRow[5];
|
||||
break;
|
||||
case 'Event':
|
||||
row.data = dbRow[16];
|
||||
break;
|
||||
case 'External':
|
||||
row.message = dbRow[17];
|
||||
row.displayName = dbRow[3];
|
||||
row.userId = dbRow[5];
|
||||
row.location = dbRow[4];
|
||||
break;
|
||||
case 'StringLoad':
|
||||
case 'ImageLoad':
|
||||
row.resourceUrl = dbRow[14];
|
||||
row.location = dbRow[4];
|
||||
break;
|
||||
}
|
||||
gamelogDatabase.push(row);
|
||||
}, `SELECT * FROM gamelog_resource_load WHERE resource_url LIKE '%${search}%' ${checkString} ${checkImage} ORDER BY id DESC LIMIT ${maxEntries}`);
|
||||
},
|
||||
`SELECT ${baseColumns} FROM (${selects.join(' UNION ALL ')}) ORDER BY created_at DESC, id DESC LIMIT @limit`,
|
||||
args
|
||||
);
|
||||
return gamelogDatabase;
|
||||
},
|
||||
|
||||
/**
|
||||
* Lookup the game log database for a specific search term
|
||||
* @param {string} search The search term
|
||||
* @param {Array} filters The filters to apply
|
||||
* @param {Array} [vipList] The list of VIP users
|
||||
* @returns {Promise<any[]>} The game log data
|
||||
*/
|
||||
|
||||
async searchGameLogDatabase(
|
||||
search,
|
||||
filters,
|
||||
vipList,
|
||||
maxEntries = dbVars.maxTableSize
|
||||
) {
|
||||
if (search.startsWith('wrld_') || search.startsWith('grp_')) {
|
||||
return this.getGameLogByLocation(search, filters);
|
||||
}
|
||||
var compareByCreatedAt = function (a, b) {
|
||||
var A = a.created_at;
|
||||
var B = b.created_at;
|
||||
if (A < B) {
|
||||
return -1;
|
||||
let vipQuery = '';
|
||||
const vipArgs = {};
|
||||
if (vipList.length > 0) {
|
||||
const vipPlaceholders = [];
|
||||
vipList.forEach((vip, i) => {
|
||||
const key = `@vip_${i}`;
|
||||
vipArgs[key] = vip;
|
||||
vipPlaceholders.push(key);
|
||||
});
|
||||
vipQuery = `AND user_id IN (${vipPlaceholders.join(', ')})`;
|
||||
}
|
||||
let location = true;
|
||||
let onplayerjoined = true;
|
||||
let onplayerleft = true;
|
||||
let portalspawn = true;
|
||||
let msgevent = true;
|
||||
let external = true;
|
||||
let videoplay = true;
|
||||
let resourceload_string = true;
|
||||
let resourceload_image = true;
|
||||
if (filters.length > 0) {
|
||||
location = false;
|
||||
onplayerjoined = false;
|
||||
onplayerleft = false;
|
||||
portalspawn = false;
|
||||
msgevent = false;
|
||||
external = false;
|
||||
videoplay = false;
|
||||
resourceload_string = false;
|
||||
resourceload_image = false;
|
||||
filters.forEach((filter) => {
|
||||
switch (filter) {
|
||||
case 'Location':
|
||||
location = true;
|
||||
break;
|
||||
case 'OnPlayerJoined':
|
||||
onplayerjoined = true;
|
||||
break;
|
||||
case 'OnPlayerLeft':
|
||||
onplayerleft = true;
|
||||
break;
|
||||
case 'PortalSpawn':
|
||||
portalspawn = true;
|
||||
break;
|
||||
case 'Event':
|
||||
msgevent = true;
|
||||
break;
|
||||
case 'External':
|
||||
external = true;
|
||||
break;
|
||||
case 'VideoPlay':
|
||||
videoplay = true;
|
||||
break;
|
||||
case 'StringLoad':
|
||||
resourceload_string = true;
|
||||
break;
|
||||
case 'ImageLoad':
|
||||
resourceload_image = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
const searchLike = `%${search}%`;
|
||||
const selects = [];
|
||||
const baseColumns = [
|
||||
'id',
|
||||
'created_at',
|
||||
'type',
|
||||
'display_name',
|
||||
'location',
|
||||
'user_id',
|
||||
'time',
|
||||
'world_id',
|
||||
'world_name',
|
||||
'group_name',
|
||||
'instance_id',
|
||||
'video_url',
|
||||
'video_name',
|
||||
'video_id',
|
||||
'resource_url',
|
||||
'resource_type',
|
||||
'data',
|
||||
'message'
|
||||
].join(', ');
|
||||
if (location) {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'Location' AS type, NULL AS display_name, location, NULL AS user_id, time, world_id, world_name, group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_location WHERE (world_name LIKE @searchLike OR group_name LIKE @searchLike) ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (onplayerjoined || onplayerleft) {
|
||||
let query = '';
|
||||
if (!onplayerjoined || !onplayerleft) {
|
||||
if (onplayerjoined) {
|
||||
query = "AND type = 'OnPlayerJoined'";
|
||||
} else if (onplayerleft) {
|
||||
query = "AND type = 'OnPlayerLeft'";
|
||||
}
|
||||
}
|
||||
if (A > B) {
|
||||
return 1;
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, type, display_name, location, user_id, time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_join_leave WHERE (display_name LIKE @searchLike AND user_id != '${dbVars.userId}') ${vipQuery} ${query} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (portalspawn) {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'PortalSpawn' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, world_name, NULL AS group_name, instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_portal_spawn WHERE (display_name LIKE @searchLike OR world_name LIKE @searchLike) ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (msgevent) {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'Event' AS type, NULL AS display_name, NULL AS location, NULL AS user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, data, NULL AS message FROM gamelog_event WHERE data LIKE @searchLike ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (external) {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'External' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, message FROM gamelog_external WHERE (display_name LIKE @searchLike OR message LIKE @searchLike) ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (videoplay) {
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, 'VideoPlay' AS type, display_name, location, user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, video_url, video_name, video_id, NULL AS resource_url, NULL AS resource_type, NULL AS data, NULL AS message FROM gamelog_video_play WHERE (video_url LIKE @searchLike OR video_name LIKE @searchLike OR display_name LIKE @searchLike) ${vipQuery} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (resourceload_string || resourceload_image) {
|
||||
let checkString = '';
|
||||
let checkImage = '';
|
||||
if (!resourceload_string) {
|
||||
checkString = `AND resource_type != 'StringLoad'`;
|
||||
}
|
||||
return 0;
|
||||
if (!resourceload_image) {
|
||||
checkString = `AND resource_type != 'ImageLoad'`;
|
||||
}
|
||||
selects.push(
|
||||
`SELECT * FROM (SELECT id, created_at, resource_type AS type, NULL AS display_name, location, NULL AS user_id, NULL AS time, NULL AS world_id, NULL AS world_name, NULL AS group_name, NULL AS instance_id, NULL AS video_url, NULL AS video_name, NULL AS video_id, resource_url, resource_type, NULL AS data, NULL AS message FROM gamelog_resource_load WHERE resource_url LIKE @searchLike ${checkString} ${checkImage} ORDER BY id DESC LIMIT @perTable)`
|
||||
);
|
||||
}
|
||||
if (selects.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const gamelogDatabase = [];
|
||||
const args = {
|
||||
'@searchLike': searchLike,
|
||||
'@limit': maxEntries,
|
||||
'@perTable': maxEntries,
|
||||
...vipArgs
|
||||
};
|
||||
gamelogDatabase.sort(compareByCreatedAt);
|
||||
if (gamelogDatabase.length > maxEntries) {
|
||||
gamelogDatabase.splice(0, gamelogDatabase.length - maxEntries);
|
||||
}
|
||||
await sqliteService.execute(
|
||||
(dbRow) => {
|
||||
const type = dbRow[2];
|
||||
const row = {
|
||||
rowId: dbRow[0],
|
||||
created_at: dbRow[1],
|
||||
type
|
||||
};
|
||||
switch (type) {
|
||||
case 'Location':
|
||||
row.location = dbRow[4];
|
||||
row.worldId = dbRow[7];
|
||||
row.worldName = dbRow[8];
|
||||
row.time = dbRow[6];
|
||||
row.groupName = dbRow[9];
|
||||
break;
|
||||
case 'OnPlayerJoined':
|
||||
case 'OnPlayerLeft':
|
||||
row.displayName = dbRow[3];
|
||||
row.location = dbRow[4];
|
||||
row.userId = dbRow[5];
|
||||
row.time = dbRow[6];
|
||||
break;
|
||||
case 'PortalSpawn':
|
||||
row.displayName = dbRow[3];
|
||||
row.location = dbRow[4];
|
||||
row.userId = dbRow[5];
|
||||
row.instanceId = dbRow[10];
|
||||
row.worldName = dbRow[8];
|
||||
break;
|
||||
case 'VideoPlay':
|
||||
row.videoUrl = dbRow[11];
|
||||
row.videoName = dbRow[12];
|
||||
row.videoId = dbRow[13];
|
||||
row.location = dbRow[4];
|
||||
row.displayName = dbRow[3];
|
||||
row.userId = dbRow[5];
|
||||
break;
|
||||
case 'Event':
|
||||
row.data = dbRow[16];
|
||||
break;
|
||||
case 'External':
|
||||
row.message = dbRow[17];
|
||||
row.displayName = dbRow[3];
|
||||
row.userId = dbRow[5];
|
||||
row.location = dbRow[4];
|
||||
break;
|
||||
case 'StringLoad':
|
||||
case 'ImageLoad':
|
||||
row.resourceUrl = dbRow[14];
|
||||
row.location = dbRow[4];
|
||||
break;
|
||||
}
|
||||
gamelogDatabase.push(row);
|
||||
},
|
||||
`SELECT ${baseColumns} FROM (${selects.join(' UNION ALL ')}) ORDER BY created_at DESC, id DESC LIMIT @limit`,
|
||||
args
|
||||
);
|
||||
return gamelogDatabase;
|
||||
},
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { reactive, ref, shallowReactive, watch } from 'vue';
|
||||
import { reactive, ref, shallowRef, watch } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { toast } from 'vue-sonner';
|
||||
|
||||
@@ -58,7 +58,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
lastLocationAvatarList: new Map()
|
||||
});
|
||||
|
||||
const gameLogTableData = shallowReactive([]);
|
||||
const gameLogTableData = shallowRef([]);
|
||||
const gameLogTable = ref({
|
||||
loading: false,
|
||||
search: '',
|
||||
@@ -88,7 +88,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
watch(
|
||||
() => watchState.isLoggedIn,
|
||||
(isLoggedIn) => {
|
||||
gameLogTableData.length = 0;
|
||||
gameLogTableData.value = [];
|
||||
if (isLoggedIn) {
|
||||
// wait for friends to load, silly but works
|
||||
workerTimers.setTimeout(() => {
|
||||
@@ -165,25 +165,25 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
|
||||
function insertGameLogSorted(entry) {
|
||||
const data = gameLogTableData;
|
||||
if (data.length === 0) {
|
||||
data.push(entry);
|
||||
if (data.value.length === 0) {
|
||||
data.value.push(entry);
|
||||
return;
|
||||
}
|
||||
if (compareGameLogRows(entry, data[0]) < 0) {
|
||||
data.unshift(entry);
|
||||
if (compareGameLogRows(entry, data.value[0]) < 0) {
|
||||
data.value.unshift(entry);
|
||||
return;
|
||||
}
|
||||
if (compareGameLogRows(entry, data[data.length - 1]) > 0) {
|
||||
data.push(entry);
|
||||
if (compareGameLogRows(entry, data[data.value.length - 1]) > 0) {
|
||||
data.value.push(entry);
|
||||
return;
|
||||
}
|
||||
for (let i = 1; i < data.length; i++) {
|
||||
for (let i = 1; i < data.value.length; i++) {
|
||||
if (compareGameLogRows(entry, data[i]) < 0) {
|
||||
data.splice(i, 0, entry);
|
||||
data.value.splice(i, 0, entry);
|
||||
return;
|
||||
}
|
||||
}
|
||||
data.push(entry);
|
||||
data.value.push(entry);
|
||||
}
|
||||
|
||||
function clearNowPlaying() {
|
||||
@@ -392,19 +392,26 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
if (gameLogTable.value.vip) {
|
||||
vipList = Array.from(friendStore.localFavoriteFriends.values());
|
||||
}
|
||||
const rows = await database.lookupGameLogDatabase(
|
||||
gameLogTable.value.search,
|
||||
gameLogTable.value.filter,
|
||||
vipList
|
||||
);
|
||||
const search = gameLogTable.value.search.trim();
|
||||
let rows = [];
|
||||
if (search) {
|
||||
rows = await database.searchGameLogDatabase(
|
||||
search,
|
||||
gameLogTable.value.filter,
|
||||
vipList
|
||||
);
|
||||
} else {
|
||||
rows = await database.lookupGameLogDatabase(
|
||||
gameLogTable.value.filter,
|
||||
vipList
|
||||
);
|
||||
}
|
||||
|
||||
for (const row of rows) {
|
||||
row.isFriend = gameLogIsFriend(row);
|
||||
row.isFavorite = gameLogIsFavorite(row);
|
||||
}
|
||||
rows.sort(compareGameLogRows);
|
||||
gameLogTableData.length = 0;
|
||||
gameLogTableData.push(...rows);
|
||||
gameLogTableData.value = rows;
|
||||
gameLogTable.value.loading = false;
|
||||
}
|
||||
|
||||
@@ -527,9 +534,9 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
}
|
||||
|
||||
function sweepGameLog() {
|
||||
const j = gameLogTableData.length;
|
||||
const j = gameLogTableData.value.length;
|
||||
if (j > vrcxStore.maxTableSize + 50) {
|
||||
gameLogTableData.splice(-50, 50);
|
||||
gameLogTableData.value.splice(-50, 50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1419,7 +1426,6 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
|
||||
async function initGameLogTable() {
|
||||
const rows = await database.lookupGameLogDatabase(
|
||||
gameLogTable.value.search,
|
||||
gameLogTable.value.filter,
|
||||
[]
|
||||
);
|
||||
@@ -1427,9 +1433,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
row.isFriend = gameLogIsFriend(row);
|
||||
row.isFavorite = gameLogIsFavorite(row);
|
||||
}
|
||||
rows.sort(compareGameLogRows);
|
||||
gameLogTableData.length = 0;
|
||||
gameLogTableData.push(...rows);
|
||||
gameLogTableData.value = rows;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -96,7 +96,6 @@ export const useLocationStore = defineStore('Location', () => {
|
||||
return;
|
||||
}
|
||||
const lastLocationArray = await database.lookupGameLogDatabase(
|
||||
'',
|
||||
['Location'],
|
||||
[],
|
||||
1
|
||||
|
||||
@@ -878,6 +878,7 @@ export const useAppearanceSettingsStore = defineStore(
|
||||
.then(async ({ ok, value }) => {
|
||||
if (!ok) return;
|
||||
if (value) {
|
||||
// TODO
|
||||
let processedValue = Number(value);
|
||||
if (processedValue > 10000) {
|
||||
processedValue = 10000;
|
||||
|
||||
@@ -152,7 +152,6 @@ export const useSharedFeedStore = defineStore('SharedFeed', () => {
|
||||
// GameLog
|
||||
if (vipFilters.length) {
|
||||
const vipGameLogRows = await database.lookupGameLogDatabase(
|
||||
'',
|
||||
vipFilters,
|
||||
vipList,
|
||||
maxEntries
|
||||
@@ -161,7 +160,6 @@ export const useSharedFeedStore = defineStore('SharedFeed', () => {
|
||||
}
|
||||
if (friendsFilters.length) {
|
||||
const friendsGameLogRows = await database.lookupGameLogDatabase(
|
||||
'',
|
||||
friendsFilters,
|
||||
friendList,
|
||||
maxEntries
|
||||
@@ -170,7 +168,6 @@ export const useSharedFeedStore = defineStore('SharedFeed', () => {
|
||||
}
|
||||
if (everyoneFilters.length) {
|
||||
const everyoneGameLogRows = await database.lookupGameLogDatabase(
|
||||
'',
|
||||
everyoneFilters,
|
||||
[],
|
||||
maxEntries
|
||||
|
||||
Reference in New Issue
Block a user