Skip to content
Open
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
45 changes: 23 additions & 22 deletions src/backend/fold_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,33 +915,34 @@ function foldBySpeakers(speakers, sessions, tracksData, reqOpts, next) {
let thumb = '';

speakers.forEach((speaker) => {
// reset thumb for each speaker to avoid carrying over previous value
thumb = '';
if (speaker.photo) {
thumb = 'images/speakers/thumbnails/' + speaker.photo.split('/').pop();
}
const allSessions = getAllSessions(speaker.sessions, sessions, tracksData);

if (allSessions.length) {
speakerslist.push({
country: speaker.country,
featured: speaker.featured,
email: speaker.email,
facebook: speaker.facebook,
github: speaker.github,
linkedin: speaker.linkedin,
twitter: speaker.twitter,
website: speaker.website,
long_biography: checkNullHtml(speaker.long_biography) ? speaker.short_biography : speaker.long_biography,
mobile: speaker.mobile,
name: speaker.name,
thumb: thumb,
photo: speaker.photo,
organisation: speaker.organisation,
position: speaker.position,
sessions: allSessions,
speaker_id: speaker.id,
nameIdSlug: slugify(speaker.name + speaker.id)
});
}
// include every speaker in the generated output, even if they have no sessions
speakerslist.push({
country: speaker.country,
featured: speaker.featured,
email: speaker.email,
facebook: speaker.facebook,
github: speaker.github,
linkedin: speaker.linkedin,
twitter: speaker.twitter,
website: speaker.website,
long_biography: checkNullHtml(speaker.long_biography) ? speaker.short_biography : speaker.long_biography,
mobile: speaker.mobile,
name: speaker.name,
thumb: thumb,
photo: speaker.photo,
organisation: speaker.organisation,
position: speaker.position,
sessions: allSessions,
speaker_id: speaker.id,
nameIdSlug: slugify(speaker.name + speaker.id)
});
speakerslist.sort(byProperty('name'));
});
next(speakerslist);
Expand Down
45 changes: 23 additions & 22 deletions src/backend/fold_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,33 +967,34 @@ function foldBySpeakers(speakers, sessions, tracksData, reqOpts, next) {
const speakerslist = [];

speakers.forEach((speaker) => {
// reset thumb for each speaker to avoid carrying over previous value
thumb = '';
if (speaker['photo-url']) {
thumb = 'images/speakers/thumbnails/' + speaker['photo-url'].split('/').pop();
}
const allSessions = getAllSessions(speaker.sessions, sessions, tracksData);

if (allSessions.length) {
speakerslist.push({
country: speaker.country,
featured: speaker['is-featured'],
email: speaker.email,
facebook: speaker.facebook,
github: speaker.github,
linkedin: speaker.linkedin,
twitter: speaker.twitter,
website: speaker.website,
long_biography: checkNullHtml(speaker['long-biography']) ? speaker['short-biography'] : speaker['long-biography'],
mobile: speaker.mobile,
name: speaker.name,
thumb: thumb,
photo: speaker['photo-url'],
organisation: speaker.organisation,
position: speaker.position,
sessions: allSessions,
speaker_id: speaker.id,
nameIdSlug: slugify(speaker.name + speaker.id)
});
}
// include every speaker in the generated output, even if they have no sessions
speakerslist.push({
country: speaker.country,
featured: speaker['is-featured'],
email: speaker.email,
facebook: speaker.facebook,
github: speaker.github,
linkedin: speaker.linkedin,
twitter: speaker.twitter,
website: speaker.website,
long_biography: checkNullHtml(speaker['long-biography']) ? speaker['short-biography'] : speaker['long-biography'],
mobile: speaker.mobile,
name: speaker.name,
thumb: thumb,
photo: speaker['photo-url'],
organisation: speaker.organisation,
position: speaker.position,
sessions: allSessions,
speaker_id: speaker.id,
nameIdSlug: slugify(speaker.name + speaker.id)
});
speakerslist.sort(byProperty('name'));
});
next(speakerslist);
Expand Down
59 changes: 59 additions & 0 deletions test/foldSpeakers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const assert = require('assert');
const fold = require('../src/backend/fold_v2');

describe('fold_v2.foldBySpeakers', function() {
it('includes speakers even if they have no sessions', function(done) {
const sessions = [
{
id: 1,
state: 'accepted',
title: 'Talk 1',
'starts-at': '2025-11-13T10:00:00Z',
'ends-at': '2025-11-13T11:00:00Z',
track: null,
microlocation: null
}
];

const speakers = [
{
id: 1,
name: 'Alice',
sessions: [{ id: 1 }],
'photo-url': null,
'short-biography': '',
'long-biography': ''
},
{
id: 2,
name: 'Bob',
sessions: [],
'photo-url': null,
'short-biography': '',
'long-biography': ''
}
];

const tracksData = [];

const reqOpts = {
assetmode: 'download',
email: '[email protected]',
name: 'Test Event',
datasource: 'mockjson',
apiendpoint: ''
};

fold.foldBySpeakers(speakers, sessions, tracksData, reqOpts, (list) => {
try {
assert.strictEqual(list.length, 2, 'Expected two speakers in the list');
const bob = list.find(s => s.name === 'Bob');
assert.ok(bob, 'Bob should be present');
assert.deepStrictEqual(bob.sessions, [], 'Bob should have empty sessions array');
done();
} catch (err) {
done(err);
}
});
});
});