Skip to content

Commit

Permalink
feat: add scheduled maintenance tasks (#320)
Browse files Browse the repository at this point in the history
* add scheduled maintenance tasks

* fix failing typecheck
  • Loading branch information
hay-kot committed Feb 27, 2023
1 parent 70297b9 commit 0255214
Show file tree
Hide file tree
Showing 25 changed files with 521 additions and 121 deletions.
10 changes: 9 additions & 1 deletion backend/app/api/handlers/v1/v1_ctrl_maint_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 24 additions & 9 deletions backend/app/api/static/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2204,13 +2204,14 @@ const docTemplate = `{
"repo.MaintenanceEntry": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
Expand All @@ -2219,42 +2220,56 @@ const docTemplate = `{
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
"repo.MaintenanceEntryCreate": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
"repo.MaintenanceEntryUpdate": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
Expand Down
33 changes: 24 additions & 9 deletions backend/app/api/static/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2196,13 +2196,14 @@
"repo.MaintenanceEntry": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
Expand All @@ -2211,42 +2212,56 @@
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
"repo.MaintenanceEntryCreate": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
"repo.MaintenanceEntryUpdate": {
"type": "object",
"properties": {
"completedDate": {
"description": "Sold",
"type": "string"
},
"cost": {
"type": "string",
"example": "0"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
},
"scheduledDate": {
"description": "Sold",
"type": "string"
}
}
},
Expand Down
24 changes: 18 additions & 6 deletions backend/app/api/static/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,41 +390,53 @@ definitions:
type: object
repo.MaintenanceEntry:
properties:
completedDate:
description: Sold
type: string
cost:
example: "0"
type: string
date:
type: string
description:
type: string
id:
type: string
name:
type: string
scheduledDate:
description: Sold
type: string
type: object
repo.MaintenanceEntryCreate:
properties:
completedDate:
description: Sold
type: string
cost:
example: "0"
type: string
date:
type: string
description:
type: string
name:
type: string
scheduledDate:
description: Sold
type: string
type: object
repo.MaintenanceEntryUpdate:
properties:
completedDate:
description: Sold
type: string
cost:
example: "0"
type: string
date:
type: string
description:
type: string
name:
type: string
scheduledDate:
description: Sold
type: string
type: object
repo.MaintenanceLog:
properties:
Expand Down
13 changes: 12 additions & 1 deletion backend/internal/data/ent/maintenanceentry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions backend/internal/data/ent/maintenanceentry/where.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0255214

Please sign in to comment.