From bef08a6b1326ec4c9ab7b60376020368cc27aa7d Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 15 Jan 2025 01:36:48 +0100 Subject: [PATCH] fix: reintroduce distinct --- upub/routes/src/activitypub/object/likes.rs | 7 ++++++- upub/routes/src/activitypub/object/shares.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/upub/routes/src/activitypub/object/likes.rs b/upub/routes/src/activitypub/object/likes.rs index 021d792..9bfe5ac 100644 --- a/upub/routes/src/activitypub/object/likes.rs +++ b/upub/routes/src/activitypub/object/likes.rs @@ -1,6 +1,6 @@ use apb::{BaseMut, CollectionMut, LD}; use axum::extract::{Path, Query, State}; -use sea_orm::{ColumnTrait, EntityTrait, Iterable, QueryFilter, QueryOrder, QuerySelect, RelationTrait, SelectColumns, Iden, EntityName}; +use sea_orm::{sea_query::IntoColumnRef, ColumnTrait, EntityName, EntityTrait, Iden, Iterable, QueryFilter, QueryOrder, QuerySelect, RelationTrait, SelectColumns}; use upub::{selector::{RichActivity, RichFillable}, Context}; use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity}; @@ -39,11 +39,16 @@ pub async fn page( let (limit, offset) = page.pagination(); let mut select = upub::model::like::Entity::find() + .distinct_on([ + (upub::model::like::Entity, upub::model::like::Column::Published).into_column_ref(), + (upub::model::activity::Entity, upub::model::activity::Column::Internal).into_column_ref(), + ]) .join(sea_orm::JoinType::InnerJoin, upub::model::like::Relation::Activities.def()) .join(sea_orm::JoinType::InnerJoin, upub::model::activity::Relation::Addressing.def()) .filter(auth.filter_activities()) .filter(upub::model::like::Column::Object.eq(internal)) .order_by_desc(upub::model::like::Column::Published) + .order_by_desc(upub::model::activity::Column::Internal) .limit(limit) .offset(offset) .select_only(); diff --git a/upub/routes/src/activitypub/object/shares.rs b/upub/routes/src/activitypub/object/shares.rs index f6075a2..824c9c7 100644 --- a/upub/routes/src/activitypub/object/shares.rs +++ b/upub/routes/src/activitypub/object/shares.rs @@ -1,6 +1,6 @@ use apb::{BaseMut, CollectionMut, LD}; use axum::extract::{Path, Query, State}; -use sea_orm::{ColumnTrait, EntityName, EntityTrait, Iden, Iterable, QueryFilter, QueryOrder, QuerySelect, RelationTrait, SelectColumns}; +use sea_orm::{sea_query::IntoColumnRef, ColumnTrait, EntityName, EntityTrait, Iden, Iterable, QueryFilter, QueryOrder, QuerySelect, RelationTrait, SelectColumns}; use upub::{selector::{RichActivity, RichFillable}, Context}; use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity}; @@ -39,11 +39,16 @@ pub async fn page( let (limit, offset) = page.pagination(); let mut select = upub::model::announce::Entity::find() + .distinct_on([ + (upub::model::announce::Entity, upub::model::announce::Column::Published).into_column_ref(), + (upub::model::activity::Entity, upub::model::activity::Column::Internal).into_column_ref(), + ]) .join(sea_orm::JoinType::InnerJoin, upub::model::announce::Relation::Activities.def()) .join(sea_orm::JoinType::InnerJoin, upub::model::activity::Relation::Addressing.def()) .filter(auth.filter_activities()) .filter(upub::model::announce::Column::Object.eq(internal)) .order_by_desc(upub::model::announce::Column::Published) + .order_by_desc(upub::model::activity::Column::Internal) .limit(limit) .offset(offset) .select_only();