Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions cli/scripts/build-m365-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,10 @@ async function readCachedEvent(dir, event) {

const sessions = await readJson(file);
if (!Array.isArray(sessions) || sessions.length === 0) fail(`${file} has no sessions`);
const seen = new Set();
for (const session of sessions) {
if (typeof session?.sessionCode !== 'string' || !session.sessionCode || session.event !== event.id) {
fail(`${file} contains a record that isn't a normalized ${event.id} session`);
}
if (seen.has(session.sessionCode)) {
fail(`${file} repeats session code ${session.sessionCode}; the search index needs unique codes per event`);
}
seen.add(session.sessionCode);
}

const metaFile = join(dir, `${event.id}-meta.json`);
Expand Down
11 changes: 10 additions & 1 deletion cli/src/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ export function buildIndex(sessions: Session[]): void {
return (doc as unknown as Record<string, string>)[fieldName] ?? '';
},
});
index.addAll(sessions);
// Some catalogs list a session once per time slot. Index only the first row
// per ID, because MiniSearch throws on duplicate IDs; findSession still
// returns every row.
const seen = new Set<string>();
index.addAll(sessions.filter((s) => {
const id = `${s.event}::${s.sessionCode}`;
if (seen.has(id)) return false;
seen.add(id);
Comment on lines +41 to +44

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is on purpose. This PR is only a guard that stops the crash. Repeated codes within one event are a temporary glitch in the Ignite 2026 catalog, and no other event has them, so I'm keeping behavior changes to a minimum. A code query that lists every time slot matches what session <code> shows, and repeats rarely fill the default limit. Catalogs without repeats behave exactly as they do on main.

return true;
}));
}

export interface SearchOptions {
Expand Down
20 changes: 20 additions & 0 deletions cli/test/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,23 @@ describe('Ignite 2026 catalog', () => {
expect(results.every((r) => r.session.event === 'ignite-2026')).toBe(true);
});
});

describe('repeated session code within an event', () => {
beforeAll(() => {
const ignitePath = join(import.meta.dirname, 'fixtures', 'ignite-2026-sample.json');
const igniteRaw: RawSession[] = JSON.parse(readFileSync(ignitePath, 'utf-8'));
const laterSlot: RawSession = { ...igniteRaw[0]!, TimeSlot: '17:45 - 19:00' };
buildIndex(normalizeCatalog([...igniteRaw, laterSlot], 'ignite-2026'));
});

it('indexes without throwing and returns the session once from search', () => {
const results = searchSessions({ query: 'Salesforce migration', event: 'ignite-2026' });
expect(results.filter((r) => r.session.sessionCode === 'LAB700')).toHaveLength(1);
});

it('returns every time slot from findSession', () => {
const slots = findSession('LAB700', 'ignite-2026').map((s) => s.timeSlot);
expect(slots).toHaveLength(2);
expect(slots).toContain('17:45 - 19:00');
});
});
Loading