aboutsummaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-07-13 12:22:15 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-07-13 12:22:15 +0200
commit90d9d819b70f68e10482954cfc461737c0165f8a (patch)
treefa5dd5b15c0c5a53d084c7b4be9fc2d7d6782491 /controller
parent4e5b2d9dfd9413ce084e64e048a57ad6e23356d3 (diff)
downloadmdir-90d9d819b70f68e10482954cfc461737c0165f8a.tar.gz
mdir-90d9d819b70f68e10482954cfc461737c0165f8a.tar.bz2
mdir-90d9d819b70f68e10482954cfc461737c0165f8a.zip
feat: Add custom css
Diffstat (limited to 'controller')
-rw-r--r--controller/controller.go11
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)
}
}()
}