chore(backend): removed extra unneeded property to pagination

This commit is contained in:
Matt Kilgore
2024-06-22 16:15:22 -04:00
parent 8a57ca41bf
commit 30abdd4d36
4 changed files with 7 additions and 12 deletions

View File

@@ -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]{