Skip to content

Commit

Permalink
timeouts, rescue no runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Creighcl committed Sep 27, 2022
1 parent 01c0751 commit 42a0200
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
22 changes: 19 additions & 3 deletions local-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
14 changes: 4 additions & 10 deletions src/get-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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], []);
Expand All @@ -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 = {};
Expand All @@ -72,7 +66,7 @@ const getSnapshot = async (lambdaEvent) => {
}

return {
runs: Object.values(fullRunList),
runs: fullRunList,
mvrs,
global: globalScanAttrs
};
Expand Down
4 changes: 4 additions & 0 deletions src/send-to-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
};
Expand Down

0 comments on commit 42a0200

Please sign in to comment.