Lots of changes around viewing tickets from css perspective logic changes nwe handlers and service triggers... just lots of stuff...
This commit is contained in:
39
handlers/admin/manualtriggers.go
Normal file
39
handlers/admin/manualtriggers.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"synlotto-website/helpers"
|
||||
"synlotto-website/services"
|
||||
)
|
||||
|
||||
func AdminTriggersHandler(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
context := helpers.TemplateContext(w, r)
|
||||
|
||||
if r.Method == http.MethodPost {
|
||||
stats, err := services.RunTicketMatching(db, "manual")
|
||||
if err != nil {
|
||||
http.Error(w, "Matching failed: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/admin/triggers?flash=Matched "+
|
||||
strconv.Itoa(stats.TicketsMatched)+" tickets, "+
|
||||
strconv.Itoa(stats.WinnersFound)+" winners.", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
// Render admin trigger page
|
||||
tmpl := template.Must(template.New("").Funcs(helpers.TemplateFuncs()).ParseFiles(
|
||||
"templates/layout.html",
|
||||
"templates/admin/triggers.html",
|
||||
))
|
||||
err := tmpl.ExecuteTemplate(w, "layout", context)
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to load page", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user