mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-02-06 10:46:46 +00:00
- Fix pnpm version mismatch in test_next_server.yml (8 → auto-detect 10) - Add concurrency group to cancel stale CI runs - Remove redundant setup-node step - Update jest.config.js for jsdom + tsx support - Add meetingStatusBatcher integration test (3 tests) - Extract createMeetingStatusBatcher factory for testability
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { create, keyResolver, windowScheduler } from "@yornaath/batshit";
|
|
import { client } from "./apiClient";
|
|
import type { components } from "../reflector-api";
|
|
|
|
type MeetingStatusResult = {
|
|
roomName: string;
|
|
active_meetings: components["schemas"]["Meeting"][];
|
|
upcoming_events: components["schemas"]["CalendarEventResponse"][];
|
|
};
|
|
|
|
const BATCH_WINDOW_MS = 10;
|
|
|
|
export function createMeetingStatusBatcher(windowMs: number = BATCH_WINDOW_MS) {
|
|
return create({
|
|
fetcher: async (roomNames: string[]): Promise<MeetingStatusResult[]> => {
|
|
const unique = [...new Set(roomNames)];
|
|
const { data } = await client.POST("/v1/rooms/meetings/bulk-status", {
|
|
body: { room_names: unique },
|
|
});
|
|
return roomNames.map((name) => ({
|
|
roomName: name,
|
|
active_meetings: data?.[name]?.active_meetings ?? [],
|
|
upcoming_events: data?.[name]?.upcoming_events ?? [],
|
|
}));
|
|
},
|
|
resolver: keyResolver("roomName"),
|
|
scheduler: windowScheduler(windowMs),
|
|
});
|
|
}
|
|
|
|
export const meetingStatusBatcher = createMeetingStatusBatcher();
|