22
33import { S3Client , GetObjectCommand , ListObjectsV2Command , PutObjectCommand , type _Object } from "@aws-sdk/client-s3" ;
44import { Handler } from "aws-lambda" ;
5- import { GameFactory , addResource } from '@abstractplay/gameslib' ;
5+ import { GameFactory , addResource , gameinfo } from '@abstractplay/gameslib' ;
66import { gunzipSync , strFromU8 } from "fflate" ;
77import { load as loadIon } from "ion-js" ;
88import { ReservoirSampler } from "../lib/ReservoirSampler" ;
@@ -13,7 +13,7 @@ import enBack from "../locales/en/apback.json";
1313const REGION = "us-east-1" ;
1414const s3 = new S3Client ( { region : REGION } ) ;
1515const DUMP_BUCKET = "abstractplay-db-dump" ;
16- const REC_BUCKET = "records .abstractplay.com" ;
16+ const REC_BUCKET = "thumbnails .abstractplay.com" ;
1717
1818type BasicRec = {
1919 Item : {
@@ -204,6 +204,20 @@ export const handler: Handler = async (event: any, context?: any) => {
204204 }
205205 console . log ( `Generated ${ allRecs . size } thumbnails` ) ;
206206
207+ // get list of production metas
208+ const metasProd = [ ...gameinfo . keys ( ) ] . sort ( ( a , b ) => {
209+ const na = gameinfo . get ( a ) . name ;
210+ const nb = gameinfo . get ( b ) . name ;
211+ if ( na < nb ) return - 1 ;
212+ else if ( na > nb ) return 1 ;
213+ return 0 ;
214+ } )
215+ . filter ( id => ! gameinfo . get ( id ) . flags . includes ( "experimental" ) ) ;
216+ const keys = [ ...allRecs . keys ( ) ] . filter ( id => ! metasProd . includes ( id ) ) ;
217+ if ( keys . length > 0 ) {
218+ console . log ( `${ keys . length } production games do not have active or completed game records, and so no thumbnail was generated: ${ JSON . stringify ( keys ) } ` ) ;
219+ }
220+
207221 // write files to S3
208222 // meta games
209223 for ( const [ meta , json ] of allRecs . entries ( ) ) {
0 commit comments