mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 22:33:50 +02:00
sweepGameLogSessionTable
This commit is contained in:
@@ -359,6 +359,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
|
||||
function addGameLog(entry) {
|
||||
gameLogSessionTable.value.push(entry);
|
||||
sweepGameLogSessionTable();
|
||||
sharedFeedStore.updateSharedFeed(false);
|
||||
if (entry.type === 'VideoPlay') {
|
||||
// event time can be before last gameLog entry
|
||||
@@ -401,6 +402,38 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
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) {
|
||||
const groupName = await getGroupName(input.location);
|
||||
const entry = {
|
||||
@@ -486,19 +519,7 @@ export const useGameLogStore = defineStore('GameLog', () => {
|
||||
data.splice(0, 50);
|
||||
}
|
||||
|
||||
const date = new Date();
|
||||
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);
|
||||
}
|
||||
sweepGameLogSessionTable();
|
||||
}
|
||||
|
||||
function addGameLogEntry(gameLog, location) {
|
||||
|
||||
Reference in New Issue
Block a user