1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

don't report latestNum of non-existent job

navigating to a non-existent job in the frontend caused a
mutating change to the buildNums map, and returing the latestNum
field caused the frontend to repeatedly try to fetch the latest
run, which could overload the backend
This commit is contained in:
Oliver Giles 2020-06-20 15:46:18 +12:00
parent 0f2e601692
commit de948c149e

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright 2015-2019 Oliver Giles /// Copyright 2015-2020 Oliver Giles
/// ///
/// This file is part of Laminar /// This file is part of Laminar
/// ///
@ -252,7 +252,8 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.set("etc", run->startedAt + lastRuntime); j.set("etc", run->startedAt + lastRuntime);
}); });
} }
j.set("latestNum", int(buildNums[scope.job])); if(auto it = buildNums.find(scope.job); it != buildNums.end())
j.set("latestNum", int(it->second));
j.startArray("artifacts"); j.startArray("artifacts");
populateArtifacts(j, scope.job, scope.num); populateArtifacts(j, scope.job, scope.num);
j.EndArray(); j.EndArray();