mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
sweepGameLogSessionTable
This commit is contained in:
+34
-13
@@ -359,6 +359,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
|||||||
|
|
||||||
function addGameLog(entry) {
|
function addGameLog(entry) {
|
||||||
gameLogSessionTable.value.push(entry);
|
gameLogSessionTable.value.push(entry);
|
||||||
|
sweepGameLogSessionTable();
|
||||||
sharedFeedStore.updateSharedFeed(false);
|
sharedFeedStore.updateSharedFeed(false);
|
||||||
if (entry.type === 'VideoPlay') {
|
if (entry.type === 'VideoPlay') {
|
||||||
// event time can be before last gameLog entry
|
// event time can be before last gameLog entry
|
||||||
@@ -401,6 +402,38 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
|||||||
uiStore.notifyMenu('game-log');
|
uiStore.notifyMenu('game-log');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sweepGameLogSessionTable() {
|
||||||
|
const data = gameLogSessionTable.value;
|
||||||
|
const k = data.length;
|
||||||
|
if (!k) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 24 hour limit
|
||||||
|
const date = new Date();
|
||||||
|
date.setDate(date.getDate() - 1);
|
||||||
|
const limit = date.toJSON();
|
||||||
|
|
||||||
|
if (data[0].created_at < limit) {
|
||||||
|
let i = 0;
|
||||||
|
while (i < k && data[i].created_at < limit) {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if (i === k) {
|
||||||
|
gameLogSessionTable.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (i) {
|
||||||
|
data.splice(0, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const maxLen = Math.floor(vrcxStore.maxTableSize * 1.5);
|
||||||
|
if (maxLen > 0 && data.length > maxLen + 100) {
|
||||||
|
data.splice(0, data.length - maxLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function addGamelogLocationToDatabase(input) {
|
async function addGamelogLocationToDatabase(input) {
|
||||||
const groupName = await getGroupName(input.location);
|
const groupName = await getGroupName(input.location);
|
||||||
const entry = {
|
const entry = {
|
||||||
@@ -486,19 +519,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
|||||||
data.splice(0, 50);
|
data.splice(0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
const date = new Date();
|
sweepGameLogSessionTable();
|
||||||
date.setDate(date.getDate() - 1); // 24 hour limit
|
|
||||||
const limit = date.toJSON();
|
|
||||||
let i = 0;
|
|
||||||
const k = gameLogSessionTable.value.length;
|
|
||||||
while (i < k && gameLogSessionTable.value[i].created_at < limit) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
if (i === k) {
|
|
||||||
gameLogSessionTable.value = [];
|
|
||||||
} else if (i) {
|
|
||||||
gameLogSessionTable.value.splice(0, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addGameLogEntry(gameLog, location) {
|
function addGameLogEntry(gameLog, location) {
|
||||||
|
|||||||
Reference in New Issue
Block a user