Skip to content

Commit

Permalink
use defaults if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
Creighcl committed Oct 6, 2022
1 parent 5fa01f9 commit b770368
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 19 deletions.
36 changes: 19 additions & 17 deletions local-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@ const doProcess = async () => {
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: [
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: [
// 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: [ 227
//166, 169, 227,
//234, 369, 370,
391, 392
],
period: 874,
afterEpoch: 0,//Date.now()-86360,
isAGlobalScan: true
// 391, 392
// 391
// ],
// period: 999
// period: 875,
// afterEpoch: 0,//Date.now()-86360,
// isAGlobalScan: true
});

console.log('success.');
Expand Down
54 changes: 52 additions & 2 deletions src/get-snapshot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,61 @@
const {
queueUntilResolved,
getMythicLeaderboard
getMythicLeaderboard,
getDb
} = require('@dungeoneer-io/nodejs-utils');
const { mapApiRunToRun } = require('./bapi-mapper/run-snapshot');
const {
COLLECTIONS,
DATABASES
} = require('./entity-enums');

const getPeriodFixture = async (periodid) => {
const fixtureCollection = await getDb()
.db(DATABASES.DEFAULT)
.collection(COLLECTIONS.PERIODFIXTURES);

console.log(`retrieving snapshot ${ periodid }`);
let snapshot;

if (periodid) {
snapshot = await fixtureCollection.findOne({ _id: periodid });
}
if (!snapshot) {
console.log('undefined or unavailable fixture, using latest');
snapshot = await fixtureCollection.findOne({}, { sort: {$natural:-1}});
}

const periodFixture = {
dungeonIds: Object.keys(snapshot.dungeonMap),
crealmIds: [...new Set(Object.values(snapshot.rlmToCrlm))],
period: snapshot._id
};

return periodFixture;
};

const getSnapshot = async (lambdaEvent) => {
const { crealmIds, dungeonIds, period, afterEpoch = 0, isAGlobalScan = false } = lambdaEvent;
let {
crealmIds,
dungeonIds,
period,
afterEpoch = 0,
isAGlobalScan = false
} = lambdaEvent;

if (!crealmIds || !dungeonIds || !period) {
const periodFixture = await getPeriodFixture(period);

if (!crealmIds) {
crealmIds = periodFixture.crealmIds;
}

if (!dungeonIds) {
dungeonIds = [periodFixture.dungeonIds[0]];
}

period = periodFixture.period;
}

const fetchLeaderboardAndTransformResult = async ({
afterEpoch,
Expand Down

0 comments on commit b770368

Please sign in to comment.