perf(realtime+data): implement perf-data-optimization and perf-realtime-scale
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m33s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m33s
## perf-data-optimization - Add @@index([name]) on User model (migration) - Add WEATHER_HISTORY_LIMIT=90 constant, apply take/orderBy on weather history queries - Replace deep includes with explicit select on all 6 list service queries - Add unstable_cache layer with revalidateTag on all list service functions - Add cache-tags.ts helpers (sessionTag, sessionsListTag, userStatsTag) - Invalidate sessionsListTag in all create/delete Server Actions ## perf-realtime-scale - Create src/lib/broadcast.ts: generic createBroadcaster factory with shared polling (one interval per active session, starts on first subscriber, stops on last) - Migrate all 6 SSE routes to use createBroadcaster — removes per-connection setInterval - Add broadcastToXxx() calls in all Server Actions after mutations for immediate push - Add SESSIONS_PAGE_SIZE=20, pagination on sessions page with loadMoreSessions action - Add "Charger plus" button with loading state and "X sur Y" counter in WorkshopTabs ## Tests - Add 19 unit tests for broadcast.ts (polling lifecycle, userId filtering, formatEvent, error resilience, session isolation) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
} from '@/services/gif-mood';
|
||||
import { Card, PageHeader } from '@/components/ui';
|
||||
import { withWorkshopType } from '@/lib/workshops';
|
||||
import { SESSIONS_PAGE_SIZE } from '@/lib/types';
|
||||
import { WorkshopTabs } from './WorkshopTabs';
|
||||
import { NewWorkshopDropdown } from './NewWorkshopDropdown';
|
||||
|
||||
@@ -84,13 +85,23 @@ export default async function SessionsPage() {
|
||||
getTeamGifMoodSessions(session.user.id),
|
||||
]);
|
||||
|
||||
// Add workshopType to each session for unified display
|
||||
const allSwotSessions = withWorkshopType(swotSessions, 'swot');
|
||||
const allMotivatorSessions = withWorkshopType(motivatorSessions, 'motivators');
|
||||
const allYearReviewSessions = withWorkshopType(yearReviewSessions, 'year-review');
|
||||
const allWeeklyCheckInSessions = withWorkshopType(weeklyCheckInSessions, 'weekly-checkin');
|
||||
const allWeatherSessions = withWorkshopType(weatherSessions, 'weather');
|
||||
const allGifMoodSessions = withWorkshopType(gifMoodSessions, 'gif-mood');
|
||||
// Track totals before slicing for pagination UI
|
||||
const totals = {
|
||||
swot: swotSessions.length,
|
||||
motivators: motivatorSessions.length,
|
||||
'year-review': yearReviewSessions.length,
|
||||
'weekly-checkin': weeklyCheckInSessions.length,
|
||||
weather: weatherSessions.length,
|
||||
'gif-mood': gifMoodSessions.length,
|
||||
};
|
||||
|
||||
// Add workshopType and slice first page
|
||||
const allSwotSessions = withWorkshopType(swotSessions.slice(0, SESSIONS_PAGE_SIZE), 'swot');
|
||||
const allMotivatorSessions = withWorkshopType(motivatorSessions.slice(0, SESSIONS_PAGE_SIZE), 'motivators');
|
||||
const allYearReviewSessions = withWorkshopType(yearReviewSessions.slice(0, SESSIONS_PAGE_SIZE), 'year-review');
|
||||
const allWeeklyCheckInSessions = withWorkshopType(weeklyCheckInSessions.slice(0, SESSIONS_PAGE_SIZE), 'weekly-checkin');
|
||||
const allWeatherSessions = withWorkshopType(weatherSessions.slice(0, SESSIONS_PAGE_SIZE), 'weather');
|
||||
const allGifMoodSessions = withWorkshopType(gifMoodSessions.slice(0, SESSIONS_PAGE_SIZE), 'gif-mood');
|
||||
|
||||
const teamSwotWithType = withWorkshopType(teamSwotSessions, 'swot');
|
||||
const teamMotivatorWithType = withWorkshopType(teamMotivatorSessions, 'motivators');
|
||||
@@ -150,6 +161,7 @@ export default async function SessionsPage() {
|
||||
weeklyCheckInSessions={allWeeklyCheckInSessions}
|
||||
weatherSessions={allWeatherSessions}
|
||||
gifMoodSessions={allGifMoodSessions}
|
||||
totals={totals}
|
||||
teamCollabSessions={[
|
||||
...teamSwotWithType,
|
||||
...teamMotivatorWithType,
|
||||
|
||||
Reference in New Issue
Block a user