Admin users: site totals (users, buyers) and short unit marks
CI / test (push) Successful in 2m3s
CI / build (push) Skipped
CI / deploy (push) Skipped

The user list shows how many users the site has and how many of them have
paid at least once (live Stripe payments; test-mode buyers counted apart),
independent of the search. The remaining units are short marks (K, Sz, E,
?, T) with a legend under the table, so the column fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-23 12:57:56 +00:00
co-authored by Claude Opus 5.5
parent 3269aaaa35
commit 3255e939c4
4 changed files with 113 additions and 18 deletions
+28
View File
@@ -3208,4 +3208,32 @@ async fn the_user_list_pages_with_a_total(pool: PgPool) {
assert_eq!((r.body["total"].as_i64(), r.body["users"].as_array().unwrap().len()), (Some(5), 2));
let r = app.get("/v1/admin/users?q=lap&limit=3&offset=3", Some(&admin)).await;
assert_eq!((r.body["total"].as_i64(), r.body["users"].as_array().unwrap().len()), (Some(4), 1));
// The counts are for the whole site, not the search. A buyer paid at least
// once (two payments still one buyer); a test-mode payment counts apart,
// an unfinished checkout not at all.
let ids: Vec<uuid::Uuid> = sqlx::query_scalar("SELECT id FROM users WHERE email LIKE 'lap%' ORDER BY email")
.fetch_all(&pool)
.await
.unwrap();
for (n, (user, live, done)) in
[(ids[0], true, true), (ids[0], true, true), (ids[1], false, true), (ids[2], true, false)]
.into_iter()
.enumerate()
{
sqlx::query(
"INSERT INTO stripe_checkouts (id, user_id, package, price_huf, live, completed_at) \
VALUES ($1, $2, 'alap', 1990, $3, CASE WHEN $4 THEN now() END)",
)
.bind(format!("cs_test_{n}"))
.bind(user)
.bind(live)
.bind(done)
.execute(&pool)
.await
.unwrap();
}
let r = app.get("/v1/admin/users?q=lap0", Some(&admin)).await;
assert_eq!(r.body["total"].as_i64(), Some(1));
assert_eq!(r.body["stats"], json!({ "users": 5, "buyers": 1, "test_buyers": 1 }));
}