diff options
Diffstat (limited to 'controller')
-rw-r--r-- | controller/controller.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/controller/controller.go b/controller/controller.go index e381bf8..c7f4145 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -2,6 +2,7 @@ package controller import ( "net/http" + "strconv" "time" "git.sr.ht/~gabrielgio/midr/db" @@ -40,7 +41,7 @@ func (e *Env) CreateEntry(c *gin.Context) { var entry db.Entry c.ShouldBind(&entry) e.Entries.Create(&entry) - e.Worker.SpawnWorker(entry.ID, entry.Link, entry.OutputFolder) + e.Worker.SpawnWorker(&entry) c.Redirect(http.StatusFound, "/") } @@ -48,6 +49,8 @@ func (e *Env) DeleteEntry(c *gin.Context) { var entry db.Entry id := c.Param("id") e.Entries.Delete(id) + u64, _ := strconv.ParseUint(id, 10, 32) + e.Worker.RemoveJob(uint(u64)) c.HTML(http.StatusOK, "entry", entry) } @@ -59,13 +62,13 @@ func (e *Env) GetJobs(c *gin.Context) { func (e *Env) StartScheduler() { e.Worker.StartReader() go func() { - for true { + for { entries := e.Entries.All() for _, entry := range entries { - e.Worker.SpawnWorker(entry.ID, entry.Link, entry.OutputFolder) + e.Worker.SpawnWorker(&entry) } - time.Sleep(30 * time.Minute) + time.Sleep(30 * time.Second) } }() } |