Skip to content

Commit

Permalink
Merge pull request #30 from rizalgowandy/arwego/feat/v2
Browse files Browse the repository at this point in the history
Rename Status Idle to Success
  • Loading branch information
rizalgowandy authored Jun 2, 2022
2 parents 2a05f6c + 48e13c1 commit 5da763a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ Then, browse to:
- http://localhost:9001/api/jobs => see the current job status as JSON response.
- http://localhost:9001/api/histories => see previous job run histories as JSON response.

![cronx](docs/screenshot/6_jobs_page.png)
![cronx](docs/screenshot/7_jobs_page.png)

## Available Status

* **Down** => Job fails to be registered.
* **Up** => Job has just been created.
* **Running** => Job is currently running.
* **Idle** => Job is waiting for next execution time.
* **Success** => Job succeeds on the last run, waiting for next run.
* **Error** => Job fails on the last run.

## Schedule Specification Format
Expand Down
Binary file added docs/screenshot/7_jobs_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (j *Job) UpdateStatus() StatusCode {
switch atomic.LoadUint32(&j.status) {
case statusRunning:
j.Status = StatusCodeRunning
case statusIdle:
j.Status = StatusCodeIdle
case statusSuccess:
j.Status = StatusCodeSuccess
case statusDown:
j.Status = StatusCodeDown
case statusError:
Expand Down Expand Up @@ -133,7 +133,7 @@ func (j *Job) Run() {
j.Error = err.Error()
atomic.StoreUint32(&j.status, statusError)
} else {
atomic.StoreUint32(&j.status, statusIdle)
atomic.StoreUint32(&j.status, statusSuccess)
}

// Record time needed to execute the whole process.
Expand Down
10 changes: 5 additions & 5 deletions job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func TestJob_Run(t *testing.T) {
name: "Success with run resulting error",
fields: fields{
Name: "Func",
Status: StatusCodeIdle,
Status: StatusCodeSuccess,
inner: Func(func(ctx context.Context) error { return errors.New("error") }),
},
},
{
name: "Success",
fields: fields{
Name: "Func",
Status: StatusCodeIdle,
Status: StatusCodeSuccess,
inner: Func(func(ctx context.Context) error { return nil }),
},
},
Expand Down Expand Up @@ -81,11 +81,11 @@ func TestJob_UpdateStatus(t *testing.T) {
want: StatusCodeRunning,
},
{
name: "StatusCodeIdle",
name: "StatusCodeSuccess",
fields: fields{
status: statusIdle,
status: statusSuccess,
},
want: StatusCodeIdle,
want: StatusCodeSuccess,
},
{
name: "StatusCodeDown",
Expand Down
4 changes: 2 additions & 2 deletions page/histories.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const historyTemplate = `
{{end}}
{{range .Data}}
<tr
{{if eq .Status "IDLE"}} class="positive"
{{if eq .Status "SUCCESS"}} class="positive"
{{else if eq .Status "ERROR"}} class="error"
{{end}}
>
Expand Down Expand Up @@ -177,7 +177,7 @@ const historyTemplate = `
{{end}}
</td>
<td>
{{if eq .Status "IDLE"}}
{{if eq .Status "SUCCESS"}}
<div class="ui green label">
SUCCESS
</div>
Expand Down
4 changes: 2 additions & 2 deletions page/histories.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
{{end}}
{{range .Data}}
<tr
{{if eq .Status "IDLE"}} class="positive"
{{if eq .Status "SUCCESS"}} class="positive"
{{else if eq .Status "ERROR"}} class="error"
{{end}}
>
Expand Down Expand Up @@ -169,7 +169,7 @@
{{end}}
</td>
<td>
{{if eq .Status "IDLE"}}
{{if eq .Status "SUCCESS"}}
<div class="ui green label">
SUCCESS
</div>
Expand Down
8 changes: 4 additions & 4 deletions page/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ const jobsTemplate = `
<div class="step">
<i class="hourglass end icon"></i>
<div class="content">
<div class="title">Idle</div>
<div class="description">Job is waiting for next execution time</div>
<div class="title">Success</div>
<div class="description">Job succeeds on the last run, waiting for next run</div>
</div>
</div>
<div class="step">
Expand Down Expand Up @@ -161,7 +161,7 @@ const jobsTemplate = `
{{range .Data}}
<tr
{{if eq .Job.Status "RUNNING"}} class="warning"
{{else if eq .Job.Status "IDLE"}} class="positive"
{{else if eq .Job.Status "SUCCESS"}} class="positive"
{{else if eq .Job.Status "DOWN"}} class="error"
{{else if eq .Job.Status "ERROR"}} class="error"
{{end}}
Expand All @@ -179,7 +179,7 @@ const jobsTemplate = `
<div class="ui yellow label">
{{.Job.Status}}
</div>
{{else if eq .Job.Status "IDLE"}}
{{else if eq .Job.Status "SUCCESS"}}
<div class="ui green label">
{{.Job.Status}}
</div>
Expand Down
8 changes: 4 additions & 4 deletions page/jobs.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<div class="step">
<i class="hourglass end icon"></i>
<div class="content">
<div class="title">Idle</div>
<div class="description">Job is waiting for next execution time</div>
<div class="title">Success</div>
<div class="description">Job succeeds on the last run, waiting for next run</div>
</div>
</div>
<div class="step">
Expand Down Expand Up @@ -153,7 +153,7 @@
{{range .Data}}
<tr
{{if eq .Job.Status "RUNNING"}} class="warning"
{{else if eq .Job.Status "IDLE"}} class="positive"
{{else if eq .Job.Status "SUCCESS"}} class="positive"
{{else if eq .Job.Status "DOWN"}} class="error"
{{else if eq .Job.Status "ERROR"}} class="error"
{{end}}
Expand All @@ -171,7 +171,7 @@
<div class="ui yellow label">
{{.Job.Status}}
</div>
{{else if eq .Job.Status "IDLE"}}
{{else if eq .Job.Status "SUCCESS"}}
<div class="ui green label">
{{.Job.Status}}
</div>
Expand Down
6 changes: 3 additions & 3 deletions status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ func (s StatusCode) String() string {
const (
// StatusCodeUp describes that current job has just been created.
StatusCodeUp StatusCode = "UP"
// StatusCodeIdle describes that current job is waiting for next execution time.
StatusCodeIdle StatusCode = "IDLE"
// StatusCodeSuccess describes that current job is waiting for next execution time.
StatusCodeSuccess StatusCode = "SUCCESS"
// StatusCodeRunning describes that current job is currently running.
StatusCodeRunning StatusCode = "RUNNING"
// StatusCodeDown describes that current job has failed to be registered.
Expand All @@ -21,7 +21,7 @@ const (

statusDown uint32 = 0
statusUp uint32 = 1
statusIdle uint32 = 2
statusSuccess uint32 = 2
statusRunning uint32 = 3
statusError uint32 = 4
)

0 comments on commit 5da763a

Please sign in to comment.