MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / scheduleSession

Function scheduleSession

scripts/seed-events.mjs:482–501  ·  view source on GitHub ↗
(session, sessionIndex, totalSessions)

Source from the content-addressed store, hash-verified

480// ---------------------------------------------------------------------------
481
482function scheduleSession(session, sessionIndex, totalSessions) {
483 const timelineMs = TIMELINE_MINUTES * 60 * 1000;
484 const now = Date.now();
485
486 // Sessions are spread across the timeline
487 const sessionStartOffset = (sessionIndex / totalSessions) * timelineMs;
488 const sessionStart = now - timelineMs + sessionStartOffset;
489
490 // Events within session: spread over 2-10 minutes
491 const sessionDurationMs = randInt(2, 10) * 60 * 1000;
492 const eventCount = session.events.length;
493
494 return session.events.map((event, i) => {
495 const eventOffset = eventCount > 1 ? (i / (eventCount - 1)) * sessionDurationMs : 0;
496 return {
497 ...event,
498 timestamp: Math.round(sessionStart + eventOffset),
499 };
500 });
501}
502
503// ---------------------------------------------------------------------------
504// Concurrency limiter

Callers 1

mainFunction · 0.85

Calls 2

randIntFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected