feat(sessions): import language tag from Sessionize Language category
Sabrina's backlog: show a per-session delivery language in the sessions
overview. Sessionize has no native language field (verified live), so the
sidecar now resolves each session's categoryItems against a session
category titled "Language" (Sessionize's own demo-endpoint pattern) and
ships it as a plain string; a native session.language wins if it ever
appears.
- migration 20261021090000: sessions.language + re-created
get_agenda / sync_sessionize_event / sync_sessionize_excel. Language
upserts with the same coalesce(excluded, existing) rule as level/area,
so a source without language never erases it. get_agenda is dropped +
re-created (OUT shape change) and re-granted to anon/authenticated.
- sidecar: transform extracted to sessionize-transform.js (unit-tested);
Excel import gains Language / Sprache / "Sprache / Language" headers.
- attendee app: third agenda filter dropdown ("All languages", only
rendered when values exist) + language pill in SessionDetail.
- admin app: Sessions search + subtitle include language.
- seed: English for all talks, German for the two German-titled sessions.
- tests: session_language_tests.sql (8 assertions, all pass),
sessionize-transform.test.js (7), transform-excel Language case; 43/43
sidecar tests, date-guard/gridsmart/session-persistence suites green.
- docs: schema.md sessions columns + next-steps.md completion entry.
Organizer precondition (Sabrina): define the "Language" category AND
enable session custom fields on the event's API/Embed page, otherwise
live syncs keep language null (Excel import is the fallback).
This commit is contained in:
1 parent
f1cc926d8b
commit
6ed249fa31
16 files changed
+922
-60
No files matched your search
@@ -42,6 +42,7 @@
|
||||
const http = require('http');
|
||||
const XLSX = require('xlsx');
|
||||
const { transformExcel } = require('./transform-excel');
|
||||
const { transform } = require('./sessionize-transform');
|
||||
const { readSessionizeSource } = require('./sessionize-source');
|
||||
const { createSessionizePoller } = require('./sessionize-poller');
|
||||
const { createFeedbackApi } = require('./feedback-api');
|
||||
@@ -255,53 +256,8 @@ function transformPretix(orders, itemNames) {
|
||||
return { attendees: [...byEmail.values()], skipped };
|
||||
}
|
||||
|
||||
// Transform the Sessionize API response into the sync_sessionize_event payload.
|
||||
// Speakers are matched by email (the key); speakers without an email are
|
||||
// skipped and reported. Sessions carry their speakers as a list of emails.
|
||||
function transform(data) {
|
||||
const speakerByEmail = new Map();
|
||||
const roomName = new Map();
|
||||
for (const r of data.rooms || []) roomName.set(r.id, r.name);
|
||||
for (const s of data.speakers || []) {
|
||||
if (s.email) speakerByEmail.set(s.id, s.email);
|
||||
}
|
||||
|
||||
const speakers = [];
|
||||
const skippedSpeakers = [];
|
||||
for (const s of data.speakers || []) {
|
||||
if (s.email && s.fullName) {
|
||||
speakers.push({ email: s.email, full_name: s.fullName, external_id: s.id });
|
||||
} else {
|
||||
skippedSpeakers.push(s.fullName || s.id || '<unknown>');
|
||||
}
|
||||
}
|
||||
|
||||
const sessions = [];
|
||||
for (const s of data.sessions || []) {
|
||||
if (!s.id || !s.title || !s.startsAt || !s.endsAt) continue;
|
||||
const speakerEmails = (s.speakers || []).map((id) => speakerByEmail.get(id)).filter(Boolean);
|
||||
sessions.push({
|
||||
external_id: s.id,
|
||||
title: s.title,
|
||||
description: s.description || null,
|
||||
room: roomName.get(s.roomId) || null,
|
||||
date: s.startsAt.slice(0, 10),
|
||||
start_time: s.startsAt.slice(11, 19),
|
||||
end_time: s.endsAt.slice(11, 19),
|
||||
// A service session is a break/lunch/closing (isServiceSession) OR a
|
||||
// plenum (isPlenumSession) — plenums are full-hall items with no pick.
|
||||
is_service_session: Boolean(s.isServiceSession || s.isPlenumSession),
|
||||
// Level + area (free-text classification for agenda filtering).
|
||||
// Sessionize's public /view/ endpoint may not expose these; if present
|
||||
// (e.g. via a custom field or a future API version) we capture them.
|
||||
level: (s.level || '').trim() || null,
|
||||
area: (s.area || s.topic || '').trim() || null,
|
||||
speakers: speakerEmails,
|
||||
});
|
||||
}
|
||||
|
||||
return { payload: { speakers, sessions }, skippedSpeakers };
|
||||
}
|
||||
// Transform the Sessionize API response into the sync_sessionize_event
|
||||
// payload — lives in sessionize-transform.js (unit-tested); imported below.
|
||||
|
||||
async function runSync(eventId) {
|
||||
if (running) throw new Error('a sync is already running');
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Transform the Sessionize API response into the sync_sessionize_event payload.
|
||||
// Speakers are matched by email (the key); speakers without an email are
|
||||
// skipped and reported. Sessions carry their speakers as a list of emails.
|
||||
//
|
||||
// Language: Sessionize has no first-class per-session language field in the
|
||||
// public API. Organizers publish it as a session CATEGORY titled "Language"
|
||||
// (their demo endpoint does exactly this), which only appears when session
|
||||
// custom fields are enabled on the event's API/Embed endpoint. We resolve the
|
||||
// session's categoryItems against that category — items arrive as bare ids
|
||||
// (/view/All) or as {id, name, categoryId} objects depending on the view. A
|
||||
// native `language` string on the session wins if Sessionize ever adds one.
|
||||
function languageItemsByName(categories) {
|
||||
const catIds = new Set();
|
||||
const itemNames = new Map();
|
||||
for (const c of categories || []) {
|
||||
if (String(c.title || '').trim().toLowerCase() === 'language') {
|
||||
catIds.add(c.id);
|
||||
for (const it of c.items || []) itemNames.set(it.id, it.name);
|
||||
}
|
||||
}
|
||||
return { catIds, itemNames };
|
||||
}
|
||||
|
||||
function pickLanguage(session, { catIds, itemNames }) {
|
||||
const direct = typeof session.language === 'string' ? session.language.trim() : '';
|
||||
if (direct) return direct || null;
|
||||
for (const it of session.categoryItems || []) {
|
||||
const id = it && typeof it === 'object' ? it.id : it;
|
||||
if (itemNames.has(id)) return itemNames.get(id) || null;
|
||||
if (it && typeof it === 'object' && catIds.has(it.categoryId) && it.name) return it.name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function transform(data) {
|
||||
const speakerByEmail = new Map();
|
||||
const roomName = new Map();
|
||||
for (const r of data.rooms || []) roomName.set(r.id, r.name);
|
||||
for (const s of data.speakers || []) {
|
||||
if (s.email) speakerByEmail.set(s.id, s.email);
|
||||
}
|
||||
const langLookup = languageItemsByName(data.categories);
|
||||
|
||||
const speakers = [];
|
||||
const skippedSpeakers = [];
|
||||
for (const s of data.speakers || []) {
|
||||
if (s.email && s.fullName) {
|
||||
speakers.push({ email: s.email, full_name: s.fullName, external_id: s.id });
|
||||
} else {
|
||||
skippedSpeakers.push(s.fullName || s.id || '<unknown>');
|
||||
}
|
||||
}
|
||||
|
||||
const sessions = [];
|
||||
for (const s of data.sessions || []) {
|
||||
if (!s.id || !s.title || !s.startsAt || !s.endsAt) continue;
|
||||
const speakerEmails = (s.speakers || []).map((id) => speakerByEmail.get(id)).filter(Boolean);
|
||||
sessions.push({
|
||||
external_id: s.id,
|
||||
title: s.title,
|
||||
description: s.description || null,
|
||||
room: roomName.get(s.roomId) || null,
|
||||
date: s.startsAt.slice(0, 10),
|
||||
start_time: s.startsAt.slice(11, 19),
|
||||
end_time: s.endsAt.slice(11, 19),
|
||||
// A service session is a break/lunch/closing (isServiceSession) OR a
|
||||
// plenum (isPlenumSession) — plenums are full-hall items with no pick.
|
||||
is_service_session: Boolean(s.isServiceSession || s.isPlenumSession),
|
||||
// Level + area (free-text classification for agenda filtering).
|
||||
// Sessionize's public /view/ endpoint may not expose these; if present
|
||||
// (e.g. via a custom field or a future API version) we capture them.
|
||||
level: (s.level || '').trim() || null,
|
||||
area: (s.area || s.topic || '').trim() || null,
|
||||
language: pickLanguage(s, langLookup),
|
||||
speakers: speakerEmails,
|
||||
});
|
||||
}
|
||||
|
||||
return { payload: { speakers, sessions }, skippedSpeakers };
|
||||
}
|
||||
|
||||
module.exports = { transform, pickLanguage, languageItemsByName };
|
||||
@@ -75,6 +75,9 @@ function transformExcel(buffer) {
|
||||
: '');
|
||||
if (!id) continue;
|
||||
const area = firstNonempty(row, ['Themenfeld / Area of Topic', 'Area', 'Topic']) || null;
|
||||
// Sessionize exports a Language column when the event uses its language
|
||||
// feature (German UI: "Sprache / Language").
|
||||
const language = firstNonempty(row, ['Sprache / Language', 'Language', 'Sprache']) || null;
|
||||
if (!sessionsById.has(id)) {
|
||||
sessionsById.set(id, {
|
||||
external_id: id,
|
||||
@@ -85,11 +88,13 @@ function transformExcel(buffer) {
|
||||
is_service_session: isServiceSession,
|
||||
level: firstNonempty(row, ['Level']) || null,
|
||||
area,
|
||||
language,
|
||||
speakers: [],
|
||||
});
|
||||
}
|
||||
const session = sessionsById.get(id);
|
||||
if (!session.area && area) session.area = area;
|
||||
if (!session.language && language) session.language = language;
|
||||
const speakerIds = firstNonempty(row, ['Speaker Ids', 'Speaker Id'])
|
||||
.split(',').map((speakerId) => speakerId.trim()).filter(Boolean);
|
||||
for (const speakerId of speakerIds) {
|
||||
|
||||
Reference in new issue
Block a user