mirror of
https://github.com/p-stream/backend.git
synced 2026-03-11 17:55:35 +00:00
increase watchparty cleanup to 30 min
This commit is contained in:
parent
f6f805ebf4
commit
62e0b545be
3 changed files with 7 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Player Status API
|
# 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
|
## Endpoints
|
||||||
|
|
||||||
|
|
@ -142,6 +142,6 @@ Get status updates for all users in a specific room.
|
||||||
|
|
||||||
## Notes
|
## 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
|
- The system keeps a maximum of 5 status updates per user per room
|
||||||
- Timestamps are in milliseconds since epoch (Unix timestamp)
|
- Timestamps are in milliseconds since epoch (Unix timestamp)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default defineEventHandler(event => {
|
||||||
const key = `${userId}:${roomCode}`;
|
const key = `${userId}:${roomCode}`;
|
||||||
const statuses = playerStatusStore.get(key) || [];
|
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 cutoffTime = Date.now() - CLEANUP_INTERVAL;
|
||||||
const recentStatuses = statuses.filter(status => status.timestamp >= cutoffTime);
|
const recentStatuses = statuses.filter(status => status.timestamp >= cutoffTime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ export interface PlayerStatus {
|
||||||
// Key: userId+roomCode, Value: Status data array
|
// Key: userId+roomCode, Value: Status data array
|
||||||
export const playerStatusStore = new Map<string, Array<PlayerStatus>>();
|
export const playerStatusStore = new Map<string, Array<PlayerStatus>>();
|
||||||
|
|
||||||
// Cleanup interval (1 minute in milliseconds)
|
// Cleanup interval (30 minutes in milliseconds)
|
||||||
export const CLEANUP_INTERVAL = 1 * 60 * 1000;
|
export const CLEANUP_INTERVAL = 30 * 60 * 1000;
|
||||||
|
|
||||||
// Clean up old status entries
|
// Clean up old status entries
|
||||||
function cleanupOldStatuses() {
|
function cleanupOldStatuses() {
|
||||||
|
|
@ -48,5 +48,5 @@ function cleanupOldStatuses() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule cleanup every 1 minute
|
// Schedule cleanup every 5 minutes
|
||||||
setInterval(cleanupOldStatuses, 1 * 60 * 1000);
|
setInterval(cleanupOldStatuses, 5 * 60 * 1000);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue