async triggers for either interval or next due, accept cron

This commit is contained in:
bel
2021-07-17 23:14:54 -06:00
parent c90cbfc7be
commit 0f8637c9ff
3 changed files with 51 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ type Task struct {
Note []string
Due time.Time
Loop time.Duration
Cron form.Cron
Index int
}
@@ -45,6 +46,7 @@ func New(r *http.Request) (*Task, error) {
Edited: time.Now(),
Due: form.ToTime(form.Get(r, "duedate")),
Loop: form.ToDuration(form.Get(r, "loop")),
Cron: form.Cron(form.Get(r, "cron")),
}
task.SetNote(form.Get(r, "note"))
return task, task.validate()
@@ -75,7 +77,8 @@ func (t *Task) MarshalJSON() ([]byte, error) {
// "dueStr":"",
// "dueInt":33330000,
// "dueTitle":"Due ",
// "loop": "1m"}
// "loop": "1m",
// "cron": "* * * * *"}
// ]}
fullFormat := "02 Jan 2006 03:04 PM"
shortFormat := "02 Jan"
@@ -112,6 +115,7 @@ func (t *Task) MarshalJSON() ([]byte, error) {
"dueInt": t.Due.Unix(),
"dueTitle": "Due ",
"loop": t.Loop.String(),
"cron": t.Cron,
}
if t.Due.IsZero() {
for k := range m {