diff --git a/local-run.js b/local-run.js index 45e27df..d9c1c48 100644 --- a/local-run.js +++ b/local-run.js @@ -12,10 +12,26 @@ const doProcess = async () => { console.log('starting.'); await handler({ - crealmIds: [100, 104, 106, 1070, 1071, 1072, 11, 1129, 113, 1136, 1138, 114, 1147, 115, 1151, 1168], - dungeonIds: [391,392,370,369], + // crealmIds: [100, 104, 106, 1070, 1071, 1072, 11, 1129, 113, 1136, 1138, 114, 1147, 115, 1151, 1168], + // dungeonIds: [391,392,370,369], + crealmIds: [ + 3694, 1168, 151, 4, 5, 3661, 127, 9, 121, 11, + 12, 1190, 104, 155, 3693, 47, 52, 53, 54, 55, + 1129, 57, 58, 3684, 60, 61, 63, 64, 3683, 67, + 1175, 69, 77, 71, 157, 73, 96, 75, 76, 78, + 154, 1136, 84, 86, 113, 125, 1138, 99, 100, 106, + 1185, 114, 115, 117, 118, 120, 158, 160, 162, 163, + 1070, 1071, 1072, 1147, 1151, 1184, 3678, 3685, 1426, 3675, + 1171, 1425, 1427, 1428, 3676, 3207, 3208, 3209, 3234, 3721, + 3726, 3723, 3725 + ], + dungeonIds: [ + //166, 169, 227, + //234, 369, 370, + 391, 392 + ], period: 873, - afterEpoch: 0, + afterEpoch: 0,//Date.now()-86360, isAGlobalScan: true }); diff --git a/package-lock.json b/package-lock.json index 9f3cf58..5ec6e58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@dungeoneer-io/nodejs-utils": "^1.1.0", + "@dungeoneer-io/nodejs-utils": "^2.0.0", "@vercel/ncc": "^0.34.0", "mongodb": "^4.9.1" }, @@ -597,9 +597,9 @@ "dev": true }, "node_modules/@dungeoneer-io/nodejs-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@dungeoneer-io/nodejs-utils/-/nodejs-utils-1.1.0.tgz", - "integrity": "sha512-syatpGjwcOCFgQpUJ+CU7HsQfRhBDfC/cxWVTIxmLTrFeaovceqVl69eFwHYt+S/9fFL0Ahh0XuuMp7DMNOHxg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@dungeoneer-io/nodejs-utils/-/nodejs-utils-2.0.0.tgz", + "integrity": "sha512-1UxZKzcs918rSExKiP8SQaz8+1rVKonfzVN8qOkFzIGubYW+Cn78RQJfQ9KPpmGlX7Bd8E3uKGf+nGumDs5cBQ==", "dependencies": { "axios": "^0.27.2", "blizzard.js": "^4.3.0", @@ -4251,9 +4251,9 @@ "dev": true }, "@dungeoneer-io/nodejs-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@dungeoneer-io/nodejs-utils/-/nodejs-utils-1.1.0.tgz", - "integrity": "sha512-syatpGjwcOCFgQpUJ+CU7HsQfRhBDfC/cxWVTIxmLTrFeaovceqVl69eFwHYt+S/9fFL0Ahh0XuuMp7DMNOHxg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@dungeoneer-io/nodejs-utils/-/nodejs-utils-2.0.0.tgz", + "integrity": "sha512-1UxZKzcs918rSExKiP8SQaz8+1rVKonfzVN8qOkFzIGubYW+Cn78RQJfQ9KPpmGlX7Bd8E3uKGf+nGumDs5cBQ==", "requires": { "axios": "^0.27.2", "blizzard.js": "^4.3.0", diff --git a/package.json b/package.json index d42dba2..c1ddf39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@dungeoneer-io/nodejs-utils": "^1.1.0", + "@dungeoneer-io/nodejs-utils": "^2.0.0", "@vercel/ncc": "^0.34.0", "mongodb": "^4.9.1" }, diff --git a/src/get-snapshot.js b/src/get-snapshot.js index 27b8c2c..777a11f 100644 --- a/src/get-snapshot.js +++ b/src/get-snapshot.js @@ -40,6 +40,7 @@ const getSnapshot = async (lambdaEvent) => { return lbData; }; + const leaderboardsToScan = crealmIds.map(realm => ({ realm })) .map(({ realm }) => dungeonIds.map(dungeon => ({ dungeon, period, realm, afterEpoch }))) .reduce((acc, arr) => [...acc, ...arr], []); @@ -49,18 +50,11 @@ const getSnapshot = async (lambdaEvent) => { leaderboardsToScan, 40, 3, - { showBar: true, debug: true } + { showBar: true, debug: true, promiseTimeoutMs: 15500 } ) .catch(o => console.log('uncaught all the way up to doProcess')); - const fullRunList = Object.assign({}, ...runLists.results - .flatMap(({ recentRuns }) => - recentRuns.map((run) => ({ - [run._id]: run - })) - ) - ); - + const fullRunList = runLists.results.flatMap(({ recentRuns }) => recentRuns); const mvrs = runLists.results.map(({ mvr }) => mvr); let globalScanAttrs = {}; @@ -72,7 +66,7 @@ const getSnapshot = async (lambdaEvent) => { } return { - runs: Object.values(fullRunList), + runs: fullRunList, mvrs, global: globalScanAttrs }; diff --git a/src/send-to-database.js b/src/send-to-database.js index 34ebf2c..b709539 100644 --- a/src/send-to-database.js +++ b/src/send-to-database.js @@ -17,6 +17,10 @@ const upsertRuns = async (runArray) => { $set: run }); }); + if (runArray.length === 0) { + console.log('no new runs'); + return; + } const results = await batch.execute(); console.log(`${runArray.length} sent, ${results.result.nUpserted} added`); };