Skip to content

Commit

Permalink
fix: dont crash when max retries exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Apr 25, 2022
1 parent ee38e88 commit a1ad666
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "climate-warehouse",
"version": "0.0.27",
"version": "0.0.28",
"private": true,
"bin": "build/server.js",
"type": "module",
Expand Down
54 changes: 30 additions & 24 deletions src/models/governance/governance.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,41 @@ class Governance extends Model {
}

static async sync() {
if (!GOVERANCE_BODY_ID || !GOVERNANCE_BODY_IP || !GOVERNANCE_BODY_PORT) {
throw new Error('Missing information in env to sync Governance data');
}
try {
if (!GOVERANCE_BODY_ID || !GOVERNANCE_BODY_IP || !GOVERNANCE_BODY_PORT) {
throw new Error('Missing information in env to sync Governance data');
}

const governanceData = await datalayer.getSubscribedStoreData(
GOVERANCE_BODY_ID,
GOVERNANCE_BODY_IP,
GOVERNANCE_BODY_PORT,
);

const governanceData = await datalayer.getSubscribedStoreData(
GOVERANCE_BODY_ID,
GOVERNANCE_BODY_IP,
GOVERNANCE_BODY_PORT,
);
const updates = [];

const updates = [];
if (governanceData.orgList) {
updates.push({
metaKey: 'orgList',
metaValue: governanceData.orgList,
confirmed: true,
});
}

if (governanceData.orgList) {
updates.push({
metaKey: 'orgList',
metaValue: governanceData.orgList,
confirmed: true,
});
}
if (governanceData.pickList) {
updates.push({
metaKey: 'pickList',
metaValue: governanceData.pickList,
confirmed: true,
});
}

if (governanceData.pickList) {
updates.push({
metaKey: 'pickList',
metaValue: governanceData.pickList,
confirmed: true,
});
await Promise.all(
updates.map(async (update) => Governance.upsert(update)),
);
} catch (error) {
console.log(error.message);
}

await Promise.all(updates.map(async (update) => Governance.upsert(update)));
}

static async updateGoveranceBodyData(keyValueArray) {
Expand Down

0 comments on commit a1ad666

Please sign in to comment.