mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 18:55:09 +02:00
replace crash with something less threatening
This commit is contained in:
parent
8eb1c0c7d5
commit
6fa45acc54
@ -2512,8 +2512,13 @@ const mutateTestScoresToDB = async function (scoreObj, month, year) {
|
||||
});
|
||||
}
|
||||
|
||||
const zeroPad = (num, places) => String(num).padStart(places, '0')
|
||||
const getScoreAtMonthYear = async function (month, year) {
|
||||
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
||||
// 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();
|
||||
let wasInCache = false;
|
||||
// See if it is cached
|
||||
@ -2539,7 +2544,8 @@ const getScoreAtMonthYear = async function (month, year) {
|
||||
// Else get it and cache it
|
||||
const url = "https://leaderboard-serverless.vercel.app/api/aggregated_stats?since=" + startTime + "&until=" + endTime;
|
||||
console.log("Getting new Orchestrator scores for " + year + "-" + month + " @ " + url);
|
||||
return https.get(url, (res) => {
|
||||
|
||||
https.get(url, (res) => {
|
||||
let body = "";
|
||||
res.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
@ -2567,7 +2573,7 @@ const getScoreAtMonthYear = async function (month, year) {
|
||||
}
|
||||
// Also update monthly stats
|
||||
mutateTestScoresToDB(scoreObj, month, year);
|
||||
return scoreObj;
|
||||
res.send(scoreObj);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
};
|
||||
@ -2575,20 +2581,10 @@ const getScoreAtMonthYear = async function (month, year) {
|
||||
}).on("error", (error) => {
|
||||
console.error(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
} else {
|
||||
res.send({});
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
res.status(400).send(err);
|
||||
|
@ -325,7 +325,7 @@ const WinnerMonth = (obj) => {
|
||||
}
|
||||
}
|
||||
let thisScore = null;
|
||||
if (thisScores) {
|
||||
if (thisScores && thisScores.scores) {
|
||||
thisScore = thisScores.scores[orch.address];
|
||||
}
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user