fix: trello faiing on minor api degradation

This commit is contained in:
Ash Monty
2022-07-09 12:52:11 +02:00
parent 7087c92d17
commit 16f0ef8533

View File

@@ -13,9 +13,18 @@ let stripeDonationCache;
async function getTrelloCache() {
const available = await trelloAPIAvailable();
if (!available) {
return {
update_time: Date.now(),
sections: []
return trelloCache || {
update_time: 0,
sections: [{
title: 'Upstream API error',
id: '',
percentage_complete: '',
progress: {
not_started: [ 'Trello API unavailable' ],
started: [],
completed: []
}
}],
};
}
@@ -83,7 +92,7 @@ async function updateTrelloCache() {
async function trelloAPIAvailable() {
const { status } = await got('https://trello.status.atlassian.com/api/v2/status.json').json();
return status.description === 'All Systems Operational';
return status.indicator !== 'major' && status.indicator !== 'critical';
}
async function getStripeDonationCache() {