openvibers/openvibe.today Commits
Today: a holiday spelled two ways is one line (#35)
Changes
@@@ -108,7 +108,8 @@ function holidaysWeek(rows, now) {const groups = new Map();for (const e of rows) {const day = dayKey(e.starts_at, e.tz);-- const key = `${day}|${e.title}`;++ // The dataset spells some names two ways ("All Saints' Day", "All Saints Day"): one line for both.++ const key = `${day}|${String(e.title).replace(/['\u2019]/g, '').toLowerCase()}`;const cc = String(e.source_id || '').split(':')[1] || '';const g = groups.get(key) || { day, title: e.title, at: e.starts_at, tz: e.tz, countries: [], id: e.id };if (cc && !g.countries.includes(cc)) g.countries.push(cc);@@@ -17,7 +17,7 @@ assert.match(pages, /kinds: \['holiday'\]/, 'and reads them on their own');const now = Date.parse('2026-10-31T12:00:00Z');const hol = (cc, title, date) => ({ id: `tev_${cc}${date}`, kind: 'holiday', title, starts_at: `${date}T00:00:00.000Z`, tz: 'UTC', status: 'scheduled', source_id: `holiday:${cc}:${date}:x` });--const rows = [hol('PL', 'All Saints\' Day', '2026-11-01'), hol('FR', 'All Saints\' Day', '2026-11-01'), hol('AT', 'All Saints\' Day', '2026-11-01'), hol('BE', 'All Saints\' Day', '2026-11-01'), hol('ES', 'All Saints\' Day', '2026-11-01'), hol('US', 'Veterans Day', '2026-11-11')];++const rows = [hol('PL', 'All Saints\' Day', '2026-11-01'), hol('FR', 'All Saints\' Day', '2026-11-01'), hol('AT', 'All Saints\' Day', '2026-11-01'), hol('BE', 'All Saints\' Day', '2026-11-01'), hol('ES', 'All Saints Day', '2026-11-01'), hol('US', 'Veterans Day', '2026-11-11')];const page = views.home({ upcoming: [], holidays: rows, now });assert.ok(page.includes('id="td-holidays"'), 'the holidays have their own section');assert.strictEqual((page.match(/<b>All Saints'? ?Day<\/b>|<b>All Saints' Day<\/b>|<b>All Saints' Day<\/b>/g) || []).length, 1, 'one line for a holiday many countries keep');
@@ -108,7 +108,8 @@ function holidaysWeek(rows, now) {
@@ -108,7 +108,8 @@ function holidaysWeek(rows, now) {
const groups = new Map();
const groups = new Map();
for (const e of rows) {
for (const e of rows) {
const day = dayKey(e.starts_at, e.tz);
const day = dayKey(e.starts_at, e.tz);
- const key = `${day}|${e.title}`;
+ // The dataset spells some names two ways ("All Saints' Day", "All Saints Day"): one line for both.
+ const key = `${day}|${String(e.title).replace(/['\u2019]/g, '').toLowerCase()}`;
const cc = String(e.source_id || '').split(':')[1] || '';
const cc = String(e.source_id || '').split(':')[1] || '';
const g = groups.get(key) || { day, title: e.title, at: e.starts_at, tz: e.tz, countries: [], id: e.id };
const g = groups.get(key) || { day, title: e.title, at: e.starts_at, tz: e.tz, countries: [], id: e.id };
if (cc && !g.countries.includes(cc)) g.countries.push(cc);
if (cc && !g.countries.includes(cc)) g.countries.push(cc);
@@ -17,7 +17,7 @@ assert.match(pages, /kinds: \['holiday'\]/, 'and reads them on their own');
@@ -17,7 +17,7 @@ assert.match(pages, /kinds: \['holiday'\]/, 'and reads them on their own');
const now = Date.parse('2026-10-31T12:00:00Z');
const now = Date.parse('2026-10-31T12:00:00Z');
const hol = (cc, title, date) => ({ id: `tev_${cc}${date}`, kind: 'holiday', title, starts_at: `${date}T00:00:00.000Z`, tz: 'UTC', status: 'scheduled', source_id: `holiday:${cc}:${date}:x` });
const hol = (cc, title, date) => ({ id: `tev_${cc}${date}`, kind: 'holiday', title, starts_at: `${date}T00:00:00.000Z`, tz: 'UTC', status: 'scheduled', source_id: `holiday:${cc}:${date}:x` });
-const rows = [hol('PL', 'All Saints\' Day', '2026-11-01'), hol('FR', 'All Saints\' Day', '2026-11-01'), hol('AT', 'All Saints\' Day', '2026-11-01'), hol('BE', 'All Saints\' Day', '2026-11-01'), hol('ES', 'All Saints\' Day', '2026-11-01'), hol('US', 'Veterans Day', '2026-11-11')];
+const rows = [hol('PL', 'All Saints\' Day', '2026-11-01'), hol('FR', 'All Saints\' Day', '2026-11-01'), hol('AT', 'All Saints\' Day', '2026-11-01'), hol('BE', 'All Saints\' Day', '2026-11-01'), hol('ES', 'All Saints Day', '2026-11-01'), hol('US', 'Veterans Day', '2026-11-11')];
const page = views.home({ upcoming: [], holidays: rows, now });
const page = views.home({ upcoming: [], holidays: rows, now });
assert.ok(page.includes('id="td-holidays"'), 'the holidays have their own section');
assert.ok(page.includes('id="td-holidays"'), 'the holidays have their own section');
assert.strictEqual((page.match(/<b>All Saints'? ?Day<\/b>|<b>All Saints' Day<\/b>|<b>All Saints' Day<\/b>/g) || []).length, 1, 'one line for a holiday many countries keep');
assert.strictEqual((page.match(/<b>All Saints'? ?Day<\/b>|<b>All Saints' Day<\/b>|<b>All Saints' Day<\/b>/g) || []).length, 1, 'one line for a holiday many countries keep');