@@ -428,26 +428,41 @@ class CachedMongoClient {
428
428
let boardGamesCache = await this . mongoClient . find ( this . propertyManager . boardGamesCollectionName , { } ) ;
429
429
if ( boardGamesCache ) {
430
430
for ( let boardGame of boardGamesCache ) {
431
- if ( this . propertyManager . experimentalBoardGameBoxRendering && ! ( "primaryColor" in boardGame ) ) {
432
- try {
433
- const image = sharp ( `${ paths . FRONTEND_STATIC_DIRECTORY_PATH } ${ boardGame . coverArtFilePath } ` ) ;
434
- const stats = await image . stats ( ) ;
435
- const primaryColor = stats . dominant ;
436
-
437
- const metadata = await image . metadata ( ) ;
438
- const ratio = metadata . width / metadata . height ;
439
-
440
- if ( boardGame . primaryColor !== primaryColor || boardGame . ratio !== ratio ) {
441
- boardGame . primaryColor = primaryColor ;
442
- boardGame . ratio = ratio ;
443
- try {
444
- await this . upsertBoardGame ( boardGame ) ;
445
- } catch ( error ) {
446
- log . error ( "MongoClient.upsertBoardGame" , error ) ;
431
+ if ( this . propertyManager . experimentalBoardGameBoxRendering ) {
432
+ if ( ! ( "primaryColor" in boardGame ) ) {
433
+ try {
434
+ const image = sharp ( `${ paths . FRONTEND_STATIC_DIRECTORY_PATH } ${ boardGame . coverArtFilePath } ` ) ;
435
+ const stats = await image . stats ( ) ;
436
+ const primaryColor = stats . dominant ;
437
+ if ( boardGame . primaryColor !== primaryColor ) {
438
+ boardGame . primaryColor = primaryColor ;
439
+ try {
440
+ await this . upsertBoardGame ( boardGame ) ;
441
+ } catch ( error ) {
442
+ log . error ( "MongoClient.upsertBoardGame" , error ) ;
443
+ }
447
444
}
445
+ } catch ( error ) {
446
+ log . error ( "sharp.stats" , error ) ;
447
+ }
448
+ }
449
+ if ( ! ( "ratio" in boardGame ) ) {
450
+ try {
451
+ const image = sharp ( `${ paths . FRONTEND_STATIC_DIRECTORY_PATH } ${ boardGame . coverArtFilePath } ` ) ;
452
+ const metadata = await image . metadata ( ) ;
453
+ const ratio = metadata . width / metadata . height ;
454
+
455
+ if ( boardGame . ratio !== ratio ) {
456
+ boardGame . ratio = ratio ;
457
+ try {
458
+ await this . upsertBoardGame ( boardGame ) ;
459
+ } catch ( error ) {
460
+ log . error ( "MongoClient.upsertBoardGame" , error ) ;
461
+ }
462
+ }
463
+ } catch ( error ) {
464
+ log . error ( "sharp.metadata" , error ) ;
448
465
}
449
- } catch ( error ) {
450
- log . error ( "sharp.stats" , error ) ;
451
466
}
452
467
}
453
468
0 commit comments