From 90d9d819b70f68e10482954cfc461737c0165f8a Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 13 Jul 2022 12:22:15 +0200 Subject: feat: Add custom css --- controller/controller.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'controller') 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) } }() } -- cgit v1.2.3