Skip to content

Commit

Permalink
Add description field to jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
saolof committed May 27, 2024
1 parent c5fd9e1 commit 6e5e6ab
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions configparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func DecodeDatabases(crontab io.Reader, usepgpass bool) (map[string]string, erro
type JobMiscOptions struct {
SkipValidation bool
AllowConcurrentJobs bool
Description string
}

type JobConfig struct {
Expand Down
1 change: 1 addition & 0 deletions crontab.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ query="analyze"

[test-healthcheck]
cronschedule="* * * * *"
description="This is a special healthcheck!"
database="test"
query="select 1"

Expand Down
1 change: 1 addition & 0 deletions pgxjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func CreateJob(jobname, dbname string, s Schedule, target, query string, misc Jo
Schedule: s,
Query: query,
config: config,
misc: misc,
monitor: monitor,
valid: true,
}, nil
Expand Down
1 change: 1 addition & 0 deletions templates/listjobs.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{ define "jobdisplay" }}
<article id="{{.Name}}"><details>
<summary style="display:flex; flex-direction:row; justify-content:space-between; align-items:baseline;"> <h3>{{ .Icon }} {{ .Name }}</h3> {{if .IsRunning}} <div class="loader" role="alert" aria-label="Running"></div> {{end}} <p> Will next run {{ .Nextrun }} </p> </summary>
{{- if .Description}}<p style="text-align:center;">{{.Description}}</p> {{- end}}
<h4> Database: </h4> <text class="{{.DatabaseIsOnFire}}"> {{ .Database }}</text>
<h4> Query: </h4> <code id="{{.Name}}_query"> {{ .Query }} </code>
<h5 style="text-align:center;"> Recent runs </h5>
Expand Down
16 changes: 9 additions & 7 deletions webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type JobDisplay struct {
Database string
Name string
Query string
Description string
Icon string
IsRunning bool
Nextrun time.Time
Expand All @@ -55,13 +56,14 @@ func computeJobDisplay(ctx context.Context, m Monitor, now time.Time, job Job) (
return display, err
}
display = JobDisplay{
Database: job.DbName,
Name: job.JobName,
Query: job.Query,
IsRunning: jobcount != 0,
Icon: "🔵",
Nextrun: job.Schedule.Next(now),
Runs: recent,
Database: job.DbName,
Name: job.JobName,
Query: job.Query,
Description: job.misc.Description,
IsRunning: jobcount != 0,
Icon: "🔵",
Nextrun: job.Schedule.Next(now),
Runs: recent,
}
if len(recent) > 0 && recent[0].Status == "failed" {
display.Icon = "🔴"
Expand Down

0 comments on commit 6e5e6ab

Please sign in to comment.