feat: add scheduled maintenance tasks (#320)

* add scheduled maintenance tasks

* fix failing typecheck
This commit is contained in:
Hayden 2023-02-26 18:42:23 -09:00 committed by GitHub
parent 70297b9d27
commit 025521431e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 521 additions and 121 deletions

View file

@ -2,6 +2,7 @@ package v1
import (
"net/http"
"strconv"
"github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/repo"
@ -66,7 +67,14 @@ func (ctrl *V1Controller) handleMaintenanceLog() server.HandlerFunc {
switch r.Method {
case http.MethodGet:
mlog, err := ctrl.repo.MaintEntry.GetLog(ctx, itemID)
completed, _ := strconv.ParseBool(r.URL.Query().Get("completed"))
scheduled, _ := strconv.ParseBool(r.URL.Query().Get("scheduled"))
query := repo.MaintenanceLogQuery{
Completed: completed,
Scheduled: scheduled,
}
mlog, err := ctrl.repo.MaintEntry.GetLog(ctx, itemID, query)
if err != nil {
log.Err(err).Msg("failed to get items")
return validate.NewRequestError(err, http.StatusInternalServerError)