Skip to content

Commit

Permalink
fix: transactions count using metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed May 17, 2023
1 parent dc11e08 commit bbc8781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/api/controllers/transaction_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (ctl *TransactionController) CountTransactions(c *gin.Context) {
WithSourceFilter(c.Query("source")).
WithDestinationFilter(c.Query("destination")).
WithStartTimeFilter(startTimeParsed).
WithEndTimeFilter(endTimeParsed)
WithEndTimeFilter(endTimeParsed).
WithMetadataFilter(c.QueryMap("metadata"))

count, err := l.(*ledger.Ledger).CountTransactions(c.Request.Context(), *txQuery)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/controllers/transaction_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,12 @@ func TestTransactions(t *testing.T) {

require.Len(t, cursor.Data, 1)
require.Equal(t, cursor.Data[0].ID, tx3.ID)
rsp = internal.CountTransactions(api, url.Values{
"metadata[priority]": []string{"high"},
})
require.Equal(t, http.StatusOK, rsp.Result().StatusCode)
require.Equal(t, "1", rsp.Header().Get("Count"))
})

t.Run("after", func(t *testing.T) {
rsp := internal.GetTransactions(api, url.Values{
Expand Down

0 comments on commit bbc8781

Please sign in to comment.