From 133e59a92380fbac8d7dd0ed2461a7a6d5624e2c Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:24:49 -0600 Subject: [PATCH] increase watchparty cleanup to 30 min --- server/api/player/README.md | 4 ++-- server/api/player/status.get.ts | 2 +- server/utils/playerStatus.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/api/player/README.md b/server/api/player/README.md index 979c10a..044837a 100644 --- a/server/api/player/README.md +++ b/server/api/player/README.md @@ -1,6 +1,6 @@ # Player Status API -This API allows for tracking and retrieving player status data for users in watch party rooms. Status data is automatically cleaned up if it's older than 1 minute. +This API allows for tracking and retrieving player status data for users in watch party rooms. Status data is automatically cleaned up if it's older than 30 minutes. ## Endpoints @@ -142,6 +142,6 @@ Get status updates for all users in a specific room. ## Notes -- Status data is automatically cleaned up if it's older than 1 minute +- Status data is automatically cleaned up if it's older than 30 minutes - The system keeps a maximum of 5 status updates per user per room - Timestamps are in milliseconds since epoch (Unix timestamp) diff --git a/server/api/player/status.get.ts b/server/api/player/status.get.ts index 60c424f..3dd5c52 100644 --- a/server/api/player/status.get.ts +++ b/server/api/player/status.get.ts @@ -33,7 +33,7 @@ export default defineEventHandler(event => { const key = `${userId}:${roomCode}`; const statuses = playerStatusStore.get(key) || []; - // Remove statuses older than 15 minutes + // Remove statuses older than the cleanup interval (30 minutes) const cutoffTime = Date.now() - CLEANUP_INTERVAL; const recentStatuses = statuses.filter(status => status.timestamp >= cutoffTime); diff --git a/server/utils/playerStatus.ts b/server/utils/playerStatus.ts index 26a14b3..39bf3dc 100644 --- a/server/utils/playerStatus.ts +++ b/server/utils/playerStatus.ts @@ -30,8 +30,8 @@ export interface PlayerStatus { // Key: userId+roomCode, Value: Status data array export const playerStatusStore = new Map>(); -// Cleanup interval (1 minute in milliseconds) -export const CLEANUP_INTERVAL = 1 * 60 * 1000; +// Cleanup interval (30 minutes in milliseconds) +export const CLEANUP_INTERVAL = 30 * 60 * 1000; // Clean up old status entries function cleanupOldStatuses() { @@ -48,5 +48,5 @@ function cleanupOldStatuses() { } } -// Schedule cleanup every 1 minute -setInterval(cleanupOldStatuses, 1 * 60 * 1000); +// Schedule cleanup every 5 minutes +setInterval(cleanupOldStatuses, 5 * 60 * 1000);