Fix length -> count for some reward + payment queries

Refactor payments_successful and payments_completed into scopes
Rewrite rewards_claimed to remove n+1 query