openvibers/openvibe.today Commits

Today: a holiday spelled two ways is one line (#35)

OP OpenVibers committed 13 days ago · 9a2fde8e86 · 2 files, +3 −2

Changes

ddiff --git a/server/views/index.js b/server/views/index.js
iindex c6ac210..ccfcbfc 100644
---- a/server/views/index.js
++++ b/server/views/index.js
@@@ -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);
ddiff --git a/test/holidays-home.test.js b/test/holidays-home.test.js
iindex 8288f2d..8b3e460 100644
---- a/test/holidays-home.test.js
++++ b/test/holidays-home.test.js
@@@ -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&#39;? ?Day<\/b>|<b>All Saints' Day<\/b>|<b>All Saints&#x27; Day<\/b>/g) || []).length, 1, 'one line for a holiday many countries keep');