diff --git a/upub/core/src/selector/query.rs b/upub/core/src/selector/query.rs index bc8e2aac..828ca8d8 100644 --- a/upub/core/src/selector/query.rs +++ b/upub/core/src/selector/query.rs @@ -94,8 +94,14 @@ impl Query { pub fn hashtags() -> Select { let mut select = model::hashtag::Entity::find() + .distinct_on([ + (model::addressing::Entity, model::addressing::Column::Published).into_column_ref(), + (model::object::Entity, model::object::Column::Internal).into_column_ref(), + ]) .join(sea_orm::JoinType::InnerJoin, model::hashtag::Relation::Objects.def()) .join(sea_orm::JoinType::InnerJoin, model::object::Relation::Addressing.def()) + .order_by(model::addressing::Column::Published, Order::Desc) + .order_by(model::object::Column::Internal, Order::Desc) .select_only(); for col in model::object::Column::iter() {