fix: community search sql offset

This commit is contained in:
trisua 2025-04-10 21:46:24 -04:00
parent 39cd25f0cc
commit 52ac144953
2 changed files with 8 additions and 11 deletions

View file

@ -52,16 +52,9 @@
</div> </div>
<div class="card-nest w-full"> <div class="card-nest w-full">
<div class="card small flex items-center justify-between gap-2"> <div class="card small flex items-center gap-2">
<div class="flex items-center gap-2"> {{ icon "trending-up" }}
{{ icon "trending-up" }} <span>{{ text "communities:label.popular_communities" }}</span>
<span>{{ text "communities:label.popular_communities" }}</span>
</div>
<a href="/communities/search" class="button quaternary small">
{{ icon "search" }}
<span>{{ text "communities:label.search" }}</span>
</a>
</div> </div>
<div class="card flex flex-col gap-2"> <div class="card flex flex-col gap-2">

View file

@ -161,7 +161,11 @@ impl DataManager {
let res = query_rows!( let res = query_rows!(
&conn, &conn,
"SELECT * FROM communities WHERE title LIKE $1 ORDER BY member_count DESC, created DESC LIMIT $2 OFFSET $3", "SELECT * FROM communities WHERE title LIKE $1 ORDER BY member_count DESC, created DESC LIMIT $2 OFFSET $3",
params![&format!("%{query}%"), &(batch as i64), &(page as i64)], params![
&format!("%{query}%"),
&(batch as i64),
&((page * batch) as i64)
],
|x| { Self::get_community_from_row(x) } |x| { Self::get_community_from_row(x) }
); );