mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
display run number for queued jobs
in the frontend and in laminarc queue/show-queued. This makes it much easier to abort/unqueue runs which have not yet started. resolves #155
This commit is contained in:
parent
549f49052a
commit
e1686d454b
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2020 Oliver Giles
|
||||
/// Copyright 2015-2021 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@ -233,7 +233,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
auto queued = laminar.listQueuedRequest().send().wait(waitScope);
|
||||
for(auto it : queued.getResult()) {
|
||||
printf("%s\n", it.cStr());
|
||||
printf("%s:%d\n", it.getJob().cStr(), it.getBuildNum());
|
||||
}
|
||||
} else if(strcmp(argv[1], "show-running") == 0) {
|
||||
if(argc != 2) {
|
||||
|
@ -5,7 +5,7 @@ interface LaminarCi {
|
||||
queue @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult, buildNum :UInt32);
|
||||
start @1 (jobName :Text, params :List(JobParam)) -> (result :MethodResult, buildNum :UInt32);
|
||||
run @2 (jobName :Text, params :List(JobParam)) -> (result :JobResult, buildNum :UInt32);
|
||||
listQueued @3 () -> (result :List(Text));
|
||||
listQueued @3 () -> (result :List(Run));
|
||||
listRunning @4 () -> (result :List(Run));
|
||||
listKnown @5 () -> (result :List(Text));
|
||||
abort @6 (run :Run) -> (result :MethodResult);
|
||||
|
@ -306,13 +306,17 @@ std::string Laminar::getStatus(MonitorScope scope) {
|
||||
j.EndObject();
|
||||
}
|
||||
j.EndArray();
|
||||
int nQueued = 0;
|
||||
j.startArray("queued");
|
||||
for(const auto& run : queuedJobs) {
|
||||
if (run->name == scope.job) {
|
||||
nQueued++;
|
||||
j.StartObject();
|
||||
j.set("number", run->build);
|
||||
j.set("result", to_string(RunState::QUEUED));
|
||||
j.set("reason", run->reason());
|
||||
j.EndObject();
|
||||
}
|
||||
}
|
||||
j.set("nQueued", nQueued);
|
||||
j.EndArray();
|
||||
db->stmt("SELECT number,startedAt FROM builds WHERE name = ? AND result = ? "
|
||||
"ORDER BY completedAt DESC LIMIT 1")
|
||||
.bind(scope.job, int(RunState::SUCCESS))
|
||||
@ -399,6 +403,8 @@ std::string Laminar::getStatus(MonitorScope scope) {
|
||||
for(const auto& run : queuedJobs) {
|
||||
j.StartObject();
|
||||
j.set("name", run->name);
|
||||
j.set("number", run->build);
|
||||
j.set("result", to_string(RunState::QUEUED));
|
||||
j.EndObject();
|
||||
}
|
||||
j.EndArray();
|
||||
@ -602,6 +608,8 @@ std::shared_ptr<Run> Laminar::queueJob(std::string name, ParamMap params) {
|
||||
.startObject("data")
|
||||
.set("name", name)
|
||||
.set("number", run->build)
|
||||
.set("result", to_string(RunState::QUEUED))
|
||||
.set("reason", run->reason())
|
||||
.EndObject();
|
||||
http->notifyEvent(j.str(), name.c_str());
|
||||
|
||||
|
@ -22,7 +22,12 @@
|
||||
<nav>
|
||||
<table class="table striped">
|
||||
<tr v-for="job in jobsQueued">
|
||||
<td><router-link :to="'jobs/'+job.name">{{job.name}}</router-link> <i>queued</i></td>
|
||||
<td>
|
||||
<span v-html="runIcon(job.result)"></span>
|
||||
<router-link :to="'jobs/'+job.name">{{job.name}}</router-link>
|
||||
<router-link :to="'jobs/'+job.name+'/'+job.number">#{{job.number}}</router-link>
|
||||
<i>queued</i>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="job in jobsRunning">
|
||||
<td>
|
||||
@ -134,15 +139,11 @@
|
||||
<th class="text-center">Duration <a class="sort" :class="(sort.field=='duration'?sort.order:'')" v-on:click="do_sort('duration')"> </a></th>
|
||||
<th class="text-center vp-sm-hide">Reason <a class="sort" :class="(sort.field=='reason'?sort.order:'')" v-on:click="do_sort('reason')"> </a></th>
|
||||
</tr></thead>
|
||||
<tr v-show="nQueued">
|
||||
<td style="width:1px"><span v-html="runIcon('queued')"></span></td>
|
||||
<td colspan="4"><i>{{nQueued}} run(s) queued</i></td>
|
||||
</tr>
|
||||
<tr v-for="job in jobsRunning.concat(jobsRecent)" track-by="$index">
|
||||
<tr v-for="job in jobsQueued.concat(jobsRunning).concat(jobsRecent)" track-by="$index">
|
||||
<td style="width:1px"><span v-html="runIcon(job.result)"></span></td>
|
||||
<td><router-link :to="'jobs/'+route.params.name+'/'+job.number">#{{job.number}}</router-link></td>
|
||||
<td class="text-center">{{formatDate(job.started)}}</td>
|
||||
<td class="text-center">{{formatDuration(job.started, job.completed)}}</td>
|
||||
<td class="text-center"><span v-if="job.result!='queued'">{{formatDate(job.started)}}</span></td>
|
||||
<td class="text-center"><span v-if="job.result!='queued'">{{formatDuration(job.started, job.completed)}}</span></td>
|
||||
<td class="text-center vp-sm-hide">{{job.reason}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -397,8 +397,8 @@ const Home = templateId => {
|
||||
data: () => state,
|
||||
methods: {
|
||||
status: function(msg) {
|
||||
state.jobsQueued = msg.queued;
|
||||
state.jobsRunning = msg.running;
|
||||
state.jobsQueued = msg.queued.reverse();
|
||||
state.jobsRunning = msg.running.reverse();
|
||||
state.jobsRecent = msg.recent;
|
||||
state.resultChanged = msg.resultChanged;
|
||||
state.lowPassRates = msg.lowPassRates;
|
||||
@ -559,11 +559,11 @@ const All = templateId => {
|
||||
const Job = templateId => {
|
||||
const state = {
|
||||
description: '',
|
||||
jobsQueued: [],
|
||||
jobsRunning: [],
|
||||
jobsRecent: [],
|
||||
lastSuccess: null,
|
||||
lastFailed: null,
|
||||
nQueued: 0,
|
||||
pages: 0,
|
||||
sort: {}
|
||||
};
|
||||
@ -575,11 +575,11 @@ const Job = templateId => {
|
||||
methods: {
|
||||
status: function(msg) {
|
||||
state.description = msg.description;
|
||||
state.jobsRunning = msg.running;
|
||||
state.jobsQueued = msg.queued.reverse();
|
||||
state.jobsRunning = msg.running.reverse();
|
||||
state.jobsRecent = msg.recent;
|
||||
state.lastSuccess = msg.lastSuccess;
|
||||
state.lastFailed = msg.lastFailed;
|
||||
state.nQueued = msg.nQueued;
|
||||
state.pages = msg.pages;
|
||||
state.sort = msg.sort;
|
||||
|
||||
@ -593,11 +593,12 @@ const Job = templateId => {
|
||||
chtBuildTime = Charts.createRunTimeChart("chartBt", msg.recent, msg.averageRuntime);
|
||||
});
|
||||
},
|
||||
job_queued: function() {
|
||||
state.nQueued++;
|
||||
job_queued: function(data) {
|
||||
state.jobsQueued.splice(0, 0, data);
|
||||
this.$forceUpdate();
|
||||
},
|
||||
job_started: function(data) {
|
||||
state.nQueued--;
|
||||
state.jobsQueued.splice(state.jobsQueued.length - data.queueIndex - 1, 1);
|
||||
state.jobsRunning.splice(0, 0, data);
|
||||
this.$forceUpdate();
|
||||
},
|
||||
|
@ -101,7 +101,9 @@ public:
|
||||
auto res = context.getResults().initResult(queue.size());
|
||||
int i = 0;
|
||||
for(auto it : queue) {
|
||||
res.set(i++, it->name);
|
||||
res[i].setJob(it->name);
|
||||
res[i].setBuildNum(it->build);
|
||||
i++;
|
||||
}
|
||||
return kj::READY_NOW;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user