Skip to content

Commit 0538dd1

Browse files
committed
Sync some more speakers
1 parent d03129b commit 0538dd1

File tree

2 files changed

+93
-34
lines changed

2 files changed

+93
-34
lines changed

scripts/sync-sched/speakers.json

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"avatar": "//avatars.sched.co/9/8e/14900019/avatar.jpg.320x320px.jpg?3f4",
106106
"role": "speaker",
107107
"tags": "",
108-
"~syncedDetailsAt": 1749492046812,
108+
"~syncedDetailsAt": 1749494949562,
109109
"company": "Independent",
110110
"position": "Software Engineer",
111111
"location": "San Francisco",
@@ -147,7 +147,7 @@
147147
"avatar": "//avatars.sched.co/2/28/21066792/avatar.jpg.320x320px.jpg?375",
148148
"role": "attendee, speaker",
149149
"tags": "",
150-
"~syncedDetailsAt": 1749492046812,
150+
"~syncedDetailsAt": 1749494949562,
151151
"company": "bol",
152152
"position": "Tech Lead",
153153
"location": "",
@@ -221,7 +221,7 @@
221221
"role": "speaker",
222222
"socialurls": [],
223223
"tags": "",
224-
"~syncedDetailsAt": 1749493186105
224+
"~syncedDetailsAt": 1749494962143
225225
},
226226
{
227227
"username": "annyce.davis",
@@ -277,7 +277,7 @@
277277
"role": "attendee, speaker",
278278
"socialurls": [],
279279
"tags": "",
280-
"~syncedDetailsAt": 1749493186105
280+
"~syncedDetailsAt": 1749494962143
281281
},
282282
{
283283
"username": "ardatanrikulu",
@@ -331,9 +331,18 @@
331331
"url": "https://the-guild.dev/",
332332
"avatar": "//avatars.sched.co/6/a9/18743810/avatar.jpg.320x320px.jpg?ec6",
333333
"role": "speaker",
334-
"socialurls": [],
334+
"socialurls": [
335+
{
336+
"service": "Twitter",
337+
"url": "https://twitter.com/enisdenjo"
338+
},
339+
{
340+
"service": "LinkedIn",
341+
"url": "https://www.linkedin.com/in/enisdenjo/"
342+
}
343+
],
335344
"tags": "",
336-
"~syncedDetailsAt": 1749493186105
345+
"~syncedDetailsAt": 1749495173014
337346
},
338347
{
339348
"username": "benjie3",
@@ -344,7 +353,7 @@
344353
"avatar": "//avatars.sched.co/b/99/18743846/avatar.jpg.320x320px.jpg?b57",
345354
"role": "speaker",
346355
"tags": "",
347-
"~syncedDetailsAt": 1749492145465,
356+
"~syncedDetailsAt": 1749494949562,
348357
"company": "Graphile",
349358
"position": "GraphQL Community Gardener",
350359
"location": "Chandler's Ford, UK",
@@ -416,9 +425,14 @@
416425
"url": "https://www.linkedin.com/in/budha-b/",
417426
"avatar": "//avatars.sched.co/1/fe/17694866/avatar.jpg.320x320px.jpg?7a7",
418427
"role": "attendee, speaker",
419-
"socialurls": [],
428+
"socialurls": [
429+
{
430+
"service": "LinkedIn",
431+
"url": "https://www.linkedin.com/in/budha-b"
432+
}
433+
],
420434
"tags": "",
421-
"~syncedDetailsAt": 1749493439527
435+
"~syncedDetailsAt": 1749495355488
422436
},
423437
{
424438
"username": "christian.ernst",
@@ -472,9 +486,14 @@
472486
"url": "https://github.com/danadajian/",
473487
"avatar": "//avatars.sched.co/a/cc/21487429/avatar.jpg.320x320px.jpg?ffa",
474488
"role": "attendee, speaker",
475-
"socialurls": [],
489+
"socialurls": [
490+
{
491+
"service": "LinkedIn",
492+
"url": "https://www.linkedin.com/in/dan-adajian-aa8aaa72"
493+
}
494+
],
476495
"tags": "",
477-
"~syncedDetailsAt": 1749493898059
496+
"~syncedDetailsAt": 1749495355488
478497
},
479498
{
480499
"username": "danielle.man",
@@ -556,9 +575,14 @@
556575
"url": "",
557576
"avatar": "//avatars.sched.co/d/91/21066813/avatar.jpg.320x320px.jpg?591",
558577
"role": "attendee, speaker",
559-
"socialurls": [],
578+
"socialurls": [
579+
{
580+
"service": "LinkedIn",
581+
"url": "https://www.linkedin.com/in/emily-li-el2857/"
582+
}
583+
],
560584
"tags": "",
561-
"~syncedDetailsAt": 1749493898059
585+
"~syncedDetailsAt": 1749495355488
562586
},
563587
{
564588
"username": "en3m",
@@ -584,9 +608,18 @@
584608
"url": "",
585609
"avatar": "//avatars.sched.co/6/74/21102110/avatar.jpg.320x320px.jpg?a37",
586610
"role": "speaker",
587-
"socialurls": [],
611+
"socialurls": [
612+
{
613+
"service": "Twitter",
614+
"url": "https://twitter.com/erik_wrede"
615+
},
616+
{
617+
"service": "LinkedIn",
618+
"url": "https://www.linkedin.com/in/erikwrede/"
619+
}
620+
],
588621
"tags": "",
589-
"~syncedDetailsAt": 1749493898059
622+
"~syncedDetailsAt": 1749495355488
590623
},
591624
{
592625
"username": "ernie.turner1",
@@ -640,9 +673,14 @@
640673
"url": "https://keadex.dev",
641674
"avatar": "//avatars.sched.co/6/8c/21496501/avatar.jpg.320x320px.jpg?5c6",
642675
"role": "attendee, speaker",
643-
"socialurls": [],
676+
"socialurls": [
677+
{
678+
"service": "LinkedIn",
679+
"url": "https://www.linkedin.com/in/giacomosimmi/"
680+
}
681+
],
644682
"tags": "",
645-
"~syncedDetailsAt": 1749493945645
683+
"~syncedDetailsAt": 1749495355488
646684
},
647685
{
648686
"username": "gilgardosh",
@@ -680,7 +718,7 @@
680718
"avatar": "//avatars.sched.co/a/20/16832291/avatar.jpg.320x320px.jpg?60d",
681719
"role": "speaker",
682720
"tags": "",
683-
"~syncedDetailsAt": 1749492022246,
721+
"~syncedDetailsAt": 1749494949561,
684722
"company": "IBM",
685723
"position": "Technical Product Manager",
686724
"location": "Santa Clara, CA",
@@ -710,9 +748,18 @@
710748
"url": "https://www.threads.net/@itamarok",
711749
"avatar": "//avatars.sched.co/b/e5/80829/avatar.jpg.320x320px.jpg?988",
712750
"role": "attendee, speaker",
713-
"socialurls": [],
751+
"socialurls": [
752+
{
753+
"service": "Facebook",
754+
"url": "https://www.facebook.com/profile.php?id=504330120"
755+
},
756+
{
757+
"service": "LinkedIn",
758+
"url": "https://linkedin.com/in/itamarkestenbaum"
759+
}
760+
],
714761
"tags": "",
715-
"~syncedDetailsAt": 1749493945645
762+
"~syncedDetailsAt": 1749495355488
716763
},
717764
{
718765
"username": "jamie855",
@@ -760,7 +807,7 @@
760807
"avatar": "//avatars.sched.co/3/77/18743876/avatar.jpg.320x320px.jpg?a1e",
761808
"role": "attendee, speaker",
762809
"tags": "",
763-
"~syncedDetailsAt": 1749492022246,
810+
"~syncedDetailsAt": 1749494949561,
764811
"company": "Apollo GraphQL",
765812
"position": "Senior Engineering Manager",
766813
"location": "Connecticut, USA",

scripts/sync-sched/sync.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ async function sync(year: number, detailsRequestsQuota: number, token: string) {
9797
await existingSchedule,
9898
await schedule,
9999
"id",
100-
{ merge: false },
101100
)
102101
printComparison(scheduleComparison, "sessions", "id")
103102

@@ -110,7 +109,7 @@ async function sync(year: number, detailsRequestsQuota: number, token: string) {
110109
await existingSpeakers,
111110
await speakers,
112111
"username",
113-
{ merge: true },
112+
{ merge: mergeSpeaker },
114113
)
115114

116115
await updateSpeakerDetails(ctx, speakerComparison, detailsRequestsQuota)
@@ -181,17 +180,13 @@ async function updateSpeakerDetails(
181180
if (location) {
182181
const [key, index] = location
183182
if (key === "changed") {
184-
comparison[key][index].new = {
185-
...comparison[key][index].new,
186-
...speaker,
187-
}
183+
comparison[key][index].new = mergeSpeaker(
184+
comparison[key][index].new,
185+
speaker,
186+
)
188187
comparison[key][index].new["~syncedDetailsAt"] = Date.now()
189188
} else {
190-
// Merge for all other categories too to preserve existing fields
191-
comparison[key][index] = {
192-
...comparison[key][index],
193-
...speaker,
194-
}
189+
comparison[key][index] = mergeSpeaker(comparison[key][index], speaker)
195190
comparison[key][index]["~syncedDetailsAt"] = Date.now()
196191
}
197192
}
@@ -227,7 +222,7 @@ function compare<T extends object>(
227222
olds: T[],
228223
news: T[],
229224
key: keyof T,
230-
options: { merge: boolean },
225+
options: { merge?: (oldItem: T, newItem: T) => T } = {},
231226
) {
232227
const oldMap = new Map(olds.map(o => [o[key], o]))
233228
const newMap = new Map(news.map(n => [n[key], n]))
@@ -245,7 +240,7 @@ function compare<T extends object>(
245240
} else {
246241
changed.push({
247242
old: oldItem,
248-
new: options.merge ? { ...oldItem, ...newItem } : newItem,
243+
new: options.merge ? options.merge(oldItem, newItem) : newItem,
249244
})
250245
}
251246
} else {
@@ -388,4 +383,21 @@ function deepStrictEqualWithoutInternals(a: unknown, b: unknown): boolean {
388383
return true
389384
}
390385

386+
/**
387+
* Merges speaker data from API with existing local data,
388+
* preserving important local fields when API returns empty values.
389+
*/
390+
function mergeSpeaker(
391+
oldSpeaker: SchedSpeaker,
392+
newSpeaker: SchedSpeaker,
393+
): SchedSpeaker {
394+
return {
395+
...oldSpeaker,
396+
...newSpeaker,
397+
socialurls: newSpeaker.socialurls?.length
398+
? newSpeaker.socialurls
399+
: oldSpeaker.socialurls,
400+
}
401+
}
402+
391403
// #endregion utility

0 commit comments

Comments
 (0)