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>
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
'use server';
|
|
|
|
import { auth } from '@/lib/auth';
|
|
import { SESSIONS_PAGE_SIZE } from '@/lib/types';
|
|
import { withWorkshopType } from '@/lib/workshops';
|
|
import { getSessionsByUserId } from '@/services/sessions';
|
|
import { getMotivatorSessionsByUserId } from '@/services/moving-motivators';
|
|
import { getYearReviewSessionsByUserId } from '@/services/year-review';
|
|
import { getWeeklyCheckInSessionsByUserId } from '@/services/weekly-checkin';
|
|
import { getWeatherSessionsByUserId } from '@/services/weather';
|
|
import { getGifMoodSessionsByUserId } from '@/services/gif-mood';
|
|
import type { WorkshopTypeId } from '@/lib/workshops';
|
|
|
|
export async function loadMoreSessions(type: WorkshopTypeId, offset: number) {
|
|
const session = await auth();
|
|
if (!session?.user?.id) return null;
|
|
|
|
const userId = session.user.id;
|
|
const limit = SESSIONS_PAGE_SIZE;
|
|
|
|
switch (type) {
|
|
case 'swot': {
|
|
const all = await getSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'swot'), total: all.length };
|
|
}
|
|
case 'motivators': {
|
|
const all = await getMotivatorSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'motivators'), total: all.length };
|
|
}
|
|
case 'year-review': {
|
|
const all = await getYearReviewSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'year-review'), total: all.length };
|
|
}
|
|
case 'weekly-checkin': {
|
|
const all = await getWeeklyCheckInSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'weekly-checkin'), total: all.length };
|
|
}
|
|
case 'weather': {
|
|
const all = await getWeatherSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'weather'), total: all.length };
|
|
}
|
|
case 'gif-mood': {
|
|
const all = await getGifMoodSessionsByUserId(userId);
|
|
return { items: withWorkshopType(all.slice(offset, offset + limit), 'gif-mood'), total: all.length };
|
|
}
|
|
default:
|
|
return null;
|
|
}
|
|
}
|