Skip to content

Commit 85481d8

Browse files
committed
add run and maxRuns to job view
1 parent ec57e5b commit 85481d8

6 files changed

Lines changed: 17 additions & 1 deletion

File tree

engine/common/host.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ type Log struct {
118118

119119
type JobExecution struct {
120120
Schedule string `json:"scheduled"`
121+
MaxRuns int `json:"maxRuns"`
122+
Runs int `json:"runs"`
121123

122124
Duration int64 `json:"duration"`
123125
Tags map[string]string `json:"tags"`

engine/engine_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func TestEngine_Scheduler(t *testing.T) {
3636
r.Equal(t, "test.js", exec.Tags["name"])
3737
r.Greater(t, exec.Duration, int64(0))
3838
r.Equal(t, "1s", exec.Schedule)
39+
r.Equal(t, -1, exec.MaxRuns)
40+
r.Equal(t, 1, exec.Runs)
3941

4042
r.Equal(t, float64(1), c.Value())
4143
},

engine/host.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func (sh *scriptHost) newJobFunc(handler func(), opt common.JobOptions, schedule
136136
if len(events.GetStores(t)) == 1 {
137137
events.SetStore(int(sh.engine.cfgEvent.Store["Default"].Size), t)
138138
}
139+
counter := 1
139140

140141
return func() {
141142
sh.Lock()
@@ -145,6 +146,8 @@ func (sh *scriptHost) newJobFunc(handler func(), opt common.JobOptions, schedule
145146

146147
exec := common.JobExecution{
147148
Schedule: schedule,
149+
MaxRuns: opt.Times,
150+
Runs: counter,
148151
Tags: tags,
149152
}
150153

@@ -169,6 +172,7 @@ func (sh *scriptHost) newJobFunc(handler func(), opt common.JobOptions, schedule
169172
handler()
170173

171174
exec.Duration = time.Now().Sub(start).Milliseconds()
175+
counter++
172176
}
173177
}
174178

examples/mokapi/http_handler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export default async function() {
150150
time: '2025-05-01T08:49:25.482366+01:00',
151151
data: {
152152
schedule: '3s',
153+
maxRuns: -1,
154+
runs: 1,
153155
duration: 2300,
154156
tags: {
155157
name: "cron",

webui/src/components/dashboard/JobCard.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ function eventData(event: ServiceEvent | null): JobExecution | null{
3333
<th scope="col" class="text-left" style="width: 30px;"></th>
3434
<th scope="col" class="text-left">Name</th>
3535
<th scope="col" class="text-left">Schedule</th>
36+
<th scope="col" class="text-center" style="width:10%">Runs</th>
37+
<th scope="col" class="text-center" style="width:10%">Max Runs</th>
3638
<th scope="col" class="text-center" style="width:15%">Time</th>
3739
<th scope="col" class="text-center" style="width: 10%">Duration</th>
3840
</tr>
@@ -43,11 +45,13 @@ function eventData(event: ServiceEvent | null): JobExecution | null{
4345
<td><i class="bi bi-chevron-right"></i><i class="bi bi-chevron-down"></i></td>
4446
<td>{{ data!.tags.name }}</td>
4547
<td>{{ data!.schedule }}</td>
48+
<td class="text-center">{{ data!.runs }}</td>
49+
<td class="text-center">{{ data!.maxRuns === -1 ? '-' : data!.maxRuns }}</td>
4650
<td class="text-center">{{ format(event.time) }}</td>
4751
<td class="text-center">{{ duration(data!.duration) }}</td>
4852
</tr>
4953
<tr class="collapse-row" :set="data = eventData(event)">
50-
<td colspan="5" v-if="data" >
54+
<td colspan="7" v-if="data" >
5155
<div class="collapse" :id="'event_'+index" style="padding: 2rem;">
5256
<h5>Logs</h5>
5357
<div class="mb-3">

webui/src/types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ interface Data {
3333

3434
interface JobExecution {
3535
schedule: string
36+
maxRuns: number
37+
runs: number
3638
duration: number
3739
tags: { [name: string]: string}
3840
logs: { level: string, message: string}[]

0 commit comments

Comments
 (0)