fix: followers was wrong because full model

This commit is contained in:
əlemi 2024-03-28 05:19:13 +01:00
parent 3725097749
commit 0ec839f42f
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -34,9 +34,11 @@ pub async fn page<const OUTGOING: bool>(
let offset = page.offset.unwrap_or(0); let offset = page.offset.unwrap_or(0);
match model::relation::Entity::find() match model::relation::Entity::find()
.filter(Condition::all().add(if OUTGOING { Follower } else { Following }.eq(ctx.uid(id.clone())))) .filter(Condition::all().add(if OUTGOING { Follower } else { Following }.eq(ctx.uid(id.clone()))))
.select_only()
.select_column(if OUTGOING { Following } else { Follower }) .select_column(if OUTGOING { Following } else { Follower })
.limit(limit) .limit(limit)
.offset(page.offset.unwrap_or(0)) .offset(page.offset.unwrap_or(0))
.into_tuple::<String>()
.all(ctx.db()).await .all(ctx.db()).await
{ {
Err(e) => { Err(e) => {
@ -49,7 +51,7 @@ pub async fn page<const OUTGOING: bool>(
&url!(ctx, "/users/{id}/{follow___}"), &url!(ctx, "/users/{id}/{follow___}"),
offset, offset,
limit, limit,
following.into_iter().map(|x| Node::link(x.following)).collect() following.into_iter().map(Node::link).collect()
).ld_context() ).ld_context()
)) ))
}, },