mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-06 03:05:10 +02:00
replace crash with something less threatening
This commit is contained in:
parent
8eb1c0c7d5
commit
6fa45acc54
@ -1890,7 +1890,7 @@ const parseOrchestrator = async function (reqAddr) {
|
|||||||
// Not found
|
// Not found
|
||||||
if (!orchestratorObj) {
|
if (!orchestratorObj) {
|
||||||
console.log("Pushing null orchestrator " + reqAddr + " @ " + now);
|
console.log("Pushing null orchestrator " + reqAddr + " @ " + now);
|
||||||
orchestratorCache.push({id: reqAddr, lastGet: now });
|
orchestratorCache.push({ id: reqAddr, lastGet: now });
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
orchestratorObj.lastGet = now;
|
orchestratorObj.lastGet = now;
|
||||||
@ -2512,8 +2512,13 @@ const mutateTestScoresToDB = async function (scoreObj, month, year) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const zeroPad = (num, places) => String(num).padStart(places, '0')
|
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
||||||
const getScoreAtMonthYear = async function (month, year) {
|
// Exports info on a given Orchestrator
|
||||||
|
apiRouter.post("/getOrchestratorScores", async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { month, year } = req.body;
|
||||||
|
if (month && year) {
|
||||||
|
// Since months get counted starting at 0
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
let wasInCache = false;
|
let wasInCache = false;
|
||||||
// See if it is cached
|
// See if it is cached
|
||||||
@ -2539,7 +2544,8 @@ const getScoreAtMonthYear = async function (month, year) {
|
|||||||
// Else get it and cache it
|
// Else get it and cache it
|
||||||
const url = "https://leaderboard-serverless.vercel.app/api/aggregated_stats?since=" + startTime + "&until=" + endTime;
|
const url = "https://leaderboard-serverless.vercel.app/api/aggregated_stats?since=" + startTime + "&until=" + endTime;
|
||||||
console.log("Getting new Orchestrator scores for " + year + "-" + month + " @ " + url);
|
console.log("Getting new Orchestrator scores for " + year + "-" + month + " @ " + url);
|
||||||
return https.get(url, (res) => {
|
|
||||||
|
https.get(url, (res) => {
|
||||||
let body = "";
|
let body = "";
|
||||||
res.on("data", (chunk) => {
|
res.on("data", (chunk) => {
|
||||||
body += chunk;
|
body += chunk;
|
||||||
@ -2567,7 +2573,7 @@ const getScoreAtMonthYear = async function (month, year) {
|
|||||||
}
|
}
|
||||||
// Also update monthly stats
|
// Also update monthly stats
|
||||||
mutateTestScoresToDB(scoreObj, month, year);
|
mutateTestScoresToDB(scoreObj, month, year);
|
||||||
return scoreObj;
|
res.send(scoreObj);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
};
|
};
|
||||||
@ -2575,20 +2581,10 @@ const getScoreAtMonthYear = async function (month, year) {
|
|||||||
}).on("error", (error) => {
|
}).on("error", (error) => {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// Exports info on a given Orchestrator
|
|
||||||
apiRouter.post("/getOrchestratorScores", async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { month, year } = req.body;
|
|
||||||
if (month && year) {
|
|
||||||
// Since months get counted starting at 0
|
|
||||||
const reqObj = await getScoreAtMonthYear(month, year);
|
|
||||||
res.send(reqObj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.send({});
|
res.send({});
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
|
@ -325,7 +325,7 @@ const WinnerMonth = (obj) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let thisScore = null;
|
let thisScore = null;
|
||||||
if (thisScores) {
|
if (thisScores && thisScores.scores) {
|
||||||
thisScore = thisScores.scores[orch.address];
|
thisScore = thisScores.scores[orch.address];
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user