mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-25 06:13:03 +02:00
Use const for task status (#18)
This commit is contained in:
@@ -60,6 +60,11 @@ type taskDisableOnlineArgs struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
const STATUS_CREATED int = 0
|
||||
const STATUS_EXECUTING int = 1
|
||||
const STATUS_FINISHED int = 2
|
||||
const STATUS_ERROR int = 3
|
||||
|
||||
// GetNextTask : Performs a MySQL query over the device's Edgebox API
|
||||
func GetNextTask() Task {
|
||||
|
||||
@@ -112,7 +117,7 @@ func ExecuteTask(task Task) Task {
|
||||
|
||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
||||
|
||||
_, err = statement.Exec(1, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement
|
||||
_, err = statement.Exec(STATUS_EXECUTING, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
@@ -221,13 +226,13 @@ func ExecuteTask(task Task) Task {
|
||||
formatedDatetime = utils.GetSQLiteFormattedDateTime(time.Now())
|
||||
|
||||
if task.Result.Valid {
|
||||
_, err = statement.Exec(2, task.Result.String, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with result info
|
||||
_, err = statement.Exec(STATUS_FINISHED, task.Result.String, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with result info
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
} else {
|
||||
_, err = statement.Exec(3, "Error", formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with Error info
|
||||
_, err = statement.Exec(STATUS_ERROR, "Error", formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with Error info
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user