mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 20:10:33 +00:00
increase watchparty cleanup to 30 min
This commit is contained in:
parent
b38f7c1c2a
commit
133e59a923
3 changed files with 7 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ export interface PlayerStatus {
|
|||
// Key: userId+roomCode, Value: Status data array
|
||||
export const playerStatusStore = new Map<string, Array<PlayerStatus>>();
|
||||
|
||||
// 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue