1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-11-02 08:34:44 +00:00

resolves #43: limit the results displayed on home page

Limit "runs per job in last 24h" and "average runtime per job"
graphs to the top 5 in each case
This commit is contained in:
Oliver Giles
2018-06-01 10:33:25 +03:00
parent fba2d226ef
commit d1ca6392a4
2 changed files with 5 additions and 5 deletions

View File

@@ -333,14 +333,14 @@ void Laminar::sendStatus(LaminarClient* client) {
}
j.EndArray();
j.startObject("buildsPerJob");
db->stmt("SELECT name, COUNT(*) FROM builds WHERE completedAt > ? GROUP BY name")
db->stmt("SELECT name, COUNT(*) c FROM builds WHERE completedAt > ? GROUP BY name ORDER BY c DESC LIMIT 5")
.bind(time(nullptr) - 86400)
.fetch<str, int>([&](str job, int count){
j.set(job.c_str(), count);
});
j.EndObject();
j.startObject("timePerJob");
db->stmt("SELECT name, AVG(completedAt-startedAt) FROM builds WHERE completedAt > ? GROUP BY name")
db->stmt("SELECT name, AVG(completedAt-startedAt) av FROM builds WHERE completedAt > ? GROUP BY name ORDER BY av DESC LIMIT 5")
.bind(time(nullptr) - 7 * 86400)
.fetch<str, uint>([&](str job, uint time){
j.set(job.c_str(), time);