Nobody has started this yet — be first.
Business impact
Support and ops staff investigating "why are so many payments failing" need to filter by state without pulling every payment and filtering client-side. GET /v1/payments always returns the 100 most recently created payments, full stop, and the state-filtered route currently 500s.
Problem
GET /v1/payments always returns the 100 most recently created payments, full stop. The handler already parses a ?state= query parameter and routes to payment.Service.ListByState when it's present -- but Service.ListByState just calls Store.ListByState, which is an unimplemented, panicking stub. Right now, GET /v1/payments?state=failed returns 500 Internal Server Error.
Current behavior
GET /v1/payments?state=failed returns 500 instead of the filtered list.
Expected behavior
GET /v1/payments?state=failed should return only payments currently in failed, same shape as the unfiltered listing.
Steps to reproduce
go run ./cmd/paystate curl -s "localhost:8080/v1/payments?state=failed"
Why this matters
Support and ops staff investigating "why are so many payments failing" need to filter by state without pulling every payment and filtering client-side. Store.List already shows the query shape (SELECT ... FROM payments ORDER BY created_at DESC LIMIT $1) -- this is the same query with one more predicate.
Suggested approach
Look at Store.List right above Store.ListByState in internal/payment/store.go for the query shape and scanPayment usage pattern to copy. You need a WHERE state = $1 clause and to shift the LIMIT parameter accordingly. Don't touch payments_state_check or any migration -- state is already a plain indexed column.
Acceptance criteria
Verification
TEST_DATABASE_URL=postgresql://... go test ./tickets/tests/... -run TestTicket07 -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b feat/list-payments-by-stateFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin feat/list-payments-by-stateSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign indocker composepaystate/paystate/go.modreplace reliable => ../reliabledocker compose up --buildpaystate/context: ..docker-compose.ymlCREATED_TIMEOUTAUTHORIZED_TIMEOUTWork the tickets in tickets/docs/ (ticket-01 through ticket-25); each names one Go test in tickets/tests/:
TEST_DATABASE_URL=postgresql://... go test ./tickets/tests/... -run TestTicket01 -v # a single ticket
TEST_DATABASE_URL=postgresql://... ./tickets/run_tickets.sh # all 25, clean pass/fail summary
Tickets that don't touch Postgres (02, 03, 04, 05, 06, 14, 15, 24) run fine without TEST_DATABASE_URL set; the rest report FAIL with a "TEST_DATABASE_URL not set" message if it's missing. make test-race runs the full go test -race -p 1 ./... suite the same way.
Level 2
Implement a feature
Extend the system within its own patterns.