A continuation of HomeBox the inventory and organization system built for the Home User
chore(backend): removed extra unneeded property to pagination
Matt Kilgore30abdd4d367e
diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.goindex ec78c7b0..857f49f6 100644--- a/backend/app/api/handlers/v1/v1_ctrl_items.go+++ b/backend/app/api/handlers/v1/v1_ctrl_items.go@@ -4,9 +4,9 @@ import ("database/sql""encoding/csv""errors"+ "math/big""net/http""strings"- "math/big""github.com/google/uuid""github.com/hay-kot/httpkit/errchain"@@ -83,13 +83,12 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {items, err := ctrl.repo.Items.QueryByGroup(ctx, ctx.GID, extractQuery(r))totalPrice := new(big.Int)for _, item := range items.Items {- totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice * 100)))+ totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice*100)))}totalPriceFloat := new(big.Float).SetInt(totalPrice)totalPriceFloat.Quo(totalPriceFloat, big.NewFloat(100))- items.TotalPrice, _ = totalPriceFloat.Float64()-+if err != nil {if errors.Is(err, sql.ErrNoRows) {return server.JSON(w, http.StatusOK, repo.PaginationResult[repo.ItemSummary]{diff --git a/backend/app/api/handlers/v1/v1_ctrl_locations.go b/backend/app/api/handlers/v1/v1_ctrl_locations.goindex 632e9d36..eff6e9c8 100644--- a/backend/app/api/handlers/v1/v1_ctrl_locations.go+++ b/backend/app/api/handlers/v1/v1_ctrl_locations.go@@ -1,10 +1,9 @@package v1import (- "net/http"- "fmt""context""math/big"+ "net/http""github.com/google/uuid""github.com/hay-kot/httpkit/errchain"@@ -93,7 +92,7 @@ func (ctrl *V1Controller) GetLocationWithPrice(auth context.Context, GID uuid.UUtotalPrice := new(big.Int)items, err := ctrl.repo.Items.QueryByGroup(auth, GID, repo.ItemQuery{LocationIDs: []uuid.UUID{ID}})for _, item := range items.Items {- totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice * 100)))+ totalPrice.Add(totalPrice, big.NewInt(int64(item.PurchasePrice*100)))}totalPriceFloat := new(big.Float).SetInt(totalPrice)diff --git a/backend/internal/data/repo/pagination.go b/backend/internal/data/repo/pagination.goindex 5f540ee4..d8878d02 100644--- a/backend/internal/data/repo/pagination.go+++ b/backend/internal/data/repo/pagination.go@@ -5,7 +5,6 @@ type PaginationResult[T any] struct {PageSize int `json:"pageSize"`Total int `json:"total"`Items []T `json:"items"`- TotalPrice float64 `json:"totalPrice"`}func calculateOffset(page, pageSize int) int {diff --git a/docs/docs/api/openapi-2.0.json b/docs/docs/api/openapi-2.0.jsonindex dab7ef77..d517beac 100644--- a/docs/docs/api/openapi-2.0.json+++ b/docs/docs/api/openapi-2.0.json@@ -1683,14 +1683,12 @@"parameters": [{"type": "string",- "example": "[email protected]","description": "string","name": "username","in": "formData"},{"type": "string",- "example": "admin","description": "string","name": "password","in": "formData"@@ -2711,8 +2709,8 @@"total": {"type": "integer"},- "updatedAt": {- "type": "string"+ "totalPrice": {+ "type": "number"}}},