Skip to content

Commit 2c256bf

Browse files
committed
Wrong bucket! And better failsafe logging
1 parent 28170ba commit 2c256bf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

utils/thumbnails.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { S3Client, GetObjectCommand, ListObjectsV2Command, PutObjectCommand, type _Object } from "@aws-sdk/client-s3";
44
import { Handler } from "aws-lambda";
5-
import { GameFactory, addResource } from '@abstractplay/gameslib';
5+
import { GameFactory, addResource, gameinfo } from '@abstractplay/gameslib';
66
import { gunzipSync, strFromU8 } from "fflate";
77
import { load as loadIon } from "ion-js";
88
import { ReservoirSampler } from "../lib/ReservoirSampler";
@@ -13,7 +13,7 @@ import enBack from "../locales/en/apback.json";
1313
const REGION = "us-east-1";
1414
const s3 = new S3Client({region: REGION});
1515
const DUMP_BUCKET = "abstractplay-db-dump";
16-
const REC_BUCKET = "records.abstractplay.com";
16+
const REC_BUCKET = "thumbnails.abstractplay.com";
1717

1818
type 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

Comments
 (0)