Skip to content

Commit

Permalink
fix(claims): 🐛 try/catch requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Feb 10, 2024
1 parent 829de8c commit f277621
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,30 @@ class AdminController {
);
out count;`;

const { data } = await axios.get(
`https://overpass.kumi.systems/api/interpreter?data=${overpassQuery.replace(
"\n",
""
)}`
);
this.core
.getLogger()
.debug(
"Getting buildings for claim " +
claim.id +
` (${i + 1}/${claims.length})`
try {
const { data } = await axios.get(
`https://overpass.kumi.systems/api/interpreter?data=${overpassQuery.replace(
"\n",
""
)}`
);
this.core
.getLogger()
.debug(
"Getting buildings for claim " +
claim.id +
` (${i + 1}/${claims.length})`
);

const updatedClaim = await this.core.getPrisma().claim.update({
where: { id: claim.id },
data: { buildings: parseInt(data?.elements[0]?.tags?.total) || 0 },
});
const updatedClaim = await this.core.getPrisma().claim.update({
where: { id: claim.id },
data: { buildings: parseInt(data?.elements[0]?.tags?.total) || 0 },
});

this.progress.buildings.done = i + 1;
this.progress.buildings.done = i + 1;
} catch (e) {
this.core.getLogger().error(e.message);
}
}
this.progress.buildings = { done: 0, total: 0 };
}
Expand Down

0 comments on commit f277621

Please sign in to comment.