1
0
Fork 0
forked from alemi/upub

fix: relation checks with accept != null

This commit is contained in:
əlemi 2024-05-30 02:10:44 +02:00
parent 31d536d3d5
commit 784be32cfb
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -73,6 +73,7 @@ impl Entity {
.to(super::actor::Column::Internal) .to(super::actor::Column::Internal)
.into() .into()
) )
.filter(Column::Accept.is_not_null())
.filter(Column::Following.eq(internal_id)) .filter(Column::Following.eq(internal_id))
.select_only() .select_only()
.select_column(super::actor::Column::Id) .select_column(super::actor::Column::Id)
@ -94,6 +95,7 @@ impl Entity {
.to(super::actor::Column::Internal) .to(super::actor::Column::Internal)
.into() .into()
) )
.filter(Column::Accept.is_not_null())
.filter(Column::Follower.eq(internal_id)) .filter(Column::Follower.eq(internal_id))
.select_only() .select_only()
.select_column(super::actor::Column::Id) .select_column(super::actor::Column::Id)
@ -107,6 +109,7 @@ impl Entity {
// TODO this is 3 queries!!! can it be optimized down to 1? // TODO this is 3 queries!!! can it be optimized down to 1?
pub fn is_following(follower: i64, following: i64) -> sea_orm::Selector<sea_orm::SelectGetableTuple<i64>> { pub fn is_following(follower: i64, following: i64) -> sea_orm::Selector<sea_orm::SelectGetableTuple<i64>> {
Entity::find() Entity::find()
.filter(Column::Accept.is_not_null())
.filter(Column::Follower.eq(follower)) .filter(Column::Follower.eq(follower))
.filter(Column::Following.eq(following)) .filter(Column::Following.eq(following))
.select_only() .select_only()