@@ -181,6 +181,19 @@ async function updateSpeakerDetails(
181
181
} )
182
182
183
183
const toUpdate = byUpdateTime . slice ( 0 , quota )
184
+ console . log ( `Fetching additional details for ${ toUpdate . length } speakers...` )
185
+ console . log (
186
+ toUpdate
187
+ . map ( s =>
188
+ [
189
+ `- ${ s . username . padEnd ( 32 , " " ) } ` ,
190
+ s [ "~syncedDetailsAt" ]
191
+ ? `last synced at ${ new Date ( s [ "~syncedDetailsAt" ] ) . toLocaleString ( ) } `
192
+ : "without details yet" ,
193
+ ] . join ( "\t" ) ,
194
+ )
195
+ . join ( "\n" ) ,
196
+ )
184
197
185
198
const limit = pLimit ( 5 )
186
199
const updated = await Promise . all (
@@ -193,15 +206,20 @@ async function updateSpeakerDetails(
193
206
const location = locations . get ( speaker . username )
194
207
if ( location ) {
195
208
const [ key , index ] = location
209
+ const current =
210
+ key === "changed" ? comparison [ key ] [ index ] . new : comparison [ key ] [ index ]
211
+
212
+ const newValue = mergeSpeaker ( current , speaker )
213
+ const diff = objectDiff ( { old : current , new : newValue } )
214
+ if ( diff . trim ( ) ) {
215
+ console . log ( diff )
216
+ }
217
+ newValue [ "~syncedDetailsAt" ] = Date . now ( )
218
+
196
219
if ( key === "changed" ) {
197
- comparison [ key ] [ index ] . new = mergeSpeaker (
198
- comparison [ key ] [ index ] . new ,
199
- speaker ,
200
- )
201
- comparison [ key ] [ index ] . new [ "~syncedDetailsAt" ] = Date . now ( )
220
+ comparison [ key ] [ index ] . new = newValue
202
221
} else {
203
- comparison [ key ] [ index ] = mergeSpeaker ( comparison [ key ] [ index ] , speaker )
204
- comparison [ key ] [ index ] [ "~syncedDetailsAt" ] = Date . now ( )
222
+ comparison [ key ] [ index ] = newValue
205
223
}
206
224
}
207
225
}
@@ -212,7 +230,7 @@ async function updateSpeakerDetails(
212
230
)
213
231
const nowUnchanged = comparison . changed
214
232
. filter ( change => deepStrictEqualWithoutInternals ( change . old , change . new ) )
215
- . map ( change => change . old )
233
+ . map ( change => change . new )
216
234
217
235
comparison . changed = actuallyChanged
218
236
comparison . unchanged . push ( ...nowUnchanged )
0 commit comments