From b18863038c5a8c79f3d25c397bd60cbcbdcc2721 Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Mon, 19 May 2025 18:55:53 +0200 Subject: [PATCH] feat(transaction): #114 add error filter --- handler/transaction.go | 1 + service/transaction.go | 7 ++++++- template/transaction/transaction.templ | 11 +++++++++++ types/transaction.go | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/handler/transaction.go b/handler/transaction.go index 78c5a46..9768c90 100644 --- a/handler/transaction.go +++ b/handler/transaction.go @@ -53,6 +53,7 @@ func (h TransactionImpl) handleTransactionPage() http.HandlerFunc { filter := types.TransactionItemsFilter{ AccountId: r.URL.Query().Get("account-id"), TreasureChestId: r.URL.Query().Get("treasure-chest-id"), + Error: r.URL.Query().Get("error"), } transactions, err := h.s.GetAll(user, filter) diff --git a/service/transaction.go b/service/transaction.go index cf628c2..6e49440 100644 --- a/service/transaction.go +++ b/service/transaction.go @@ -254,7 +254,12 @@ func (s TransactionImpl) GetAll(user *types.User, filter types.TransactionItemsF WHERE user_id = ? AND (? = '' OR account_id = ?) AND (? = '' OR treasure_chest_id = ?) - ORDER BY timestamp DESC`, user.Id, filter.AccountId, filter.AccountId, filter.TreasureChestId, filter.TreasureChestId) + AND (? = '' + OR (? = "true" AND error IS NOT NULL) + OR (? = "false" AND error IS NULL) + ) + ORDER BY timestamp DESC`, + user.Id, filter.AccountId, filter.AccountId, filter.TreasureChestId, filter.TreasureChestId, filter.Error, filter.Error, filter.Error) err = db.TransformAndLogDbError("transaction GetAll", nil, err) if err != nil { return nil, err diff --git a/template/transaction/transaction.templ b/template/transaction/transaction.templ index 2faea53..d141443 100644 --- a/template/transaction/transaction.templ +++ b/template/transaction/transaction.templ @@ -41,6 +41,17 @@ templ Transaction(items templ.Component, filter types.TransactionItemsFilter, ac } } +