bugfix: GET /me/bookmarks returns total count (0.19.2)

The profile overview's bookmark counter showed 0 even when the user had bookmarks because /me/bookmarks left page.total null. Repo now returns the count alongside the rows; handler uses with_total.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-05-17 18:41:27 +02:00
parent 58e637085d
commit 21f44cea3f
6 changed files with 17 additions and 8 deletions

View File

@@ -46,7 +46,7 @@ pub async fn list_for_user(
user_id: Uuid,
limit: i64,
offset: i64,
) -> AppResult<Vec<BookmarkSummary>> {
) -> AppResult<(Vec<BookmarkSummary>, i64)> {
let rows = sqlx::query_as::<_, BookmarkSummary>(
r#"
SELECT
@@ -72,7 +72,12 @@ pub async fn list_for_user(
.bind(offset)
.fetch_all(pool)
.await?;
Ok(rows)
let (total,): (i64,) =
sqlx::query_as("SELECT count(*) FROM bookmarks WHERE user_id = $1")
.bind(user_id)
.fetch_one(pool)
.await?;
Ok((rows, total))
}
pub async fn find_owner(pool: &PgPool, id: Uuid) -> AppResult<Option<Uuid>> {