forked from alemi/upub
fix: ughh bug came back?
This commit is contained in:
parent
6e4f492069
commit
2542c98fe4
1 changed files with 10 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
use apb::{ActivityMut, ObjectMut};
|
||||
use sea_orm::{sea_query::IntoCondition, ColumnTrait, Condition, ConnectionTrait, DbErr, EntityName, EntityTrait, FromQueryResult, Iden, Iterable, LoaderTrait, ModelTrait, Order, QueryFilter, QueryOrder, QueryResult, QuerySelect, RelationTrait, Select, SelectColumns};
|
||||
use sea_orm::{sea_query::{IntoColumnRef, IntoCondition}, ColumnTrait, Condition, ConnectionTrait, DbErr, EntityName, EntityTrait, FromQueryResult, Iden, Iterable, LoaderTrait, ModelTrait, Order, QueryFilter, QueryOrder, QueryResult, QuerySelect, RelationTrait, Select, SelectColumns};
|
||||
|
||||
use crate::model;
|
||||
|
||||
|
@ -8,7 +8,10 @@ pub struct Query;
|
|||
impl Query {
|
||||
pub fn activities(my_id: Option<i64>) -> Select<model::addressing::Entity> {
|
||||
let mut select = model::addressing::Entity::find()
|
||||
.distinct_on([(model::activity::Entity, model::activity::Column::Internal)])
|
||||
.distinct_on([
|
||||
(model::addressing::Entity, model::addressing::Column::Published).into_column_ref(),
|
||||
(model::activity::Entity, model::activity::Column::Internal).into_column_ref(),
|
||||
])
|
||||
.join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Activities.def())
|
||||
.join(sea_orm::JoinType::LeftJoin, model::addressing::Relation::Objects.def())
|
||||
.filter(
|
||||
|
@ -17,8 +20,8 @@ impl Query {
|
|||
.add(model::activity::Column::Id.is_not_null())
|
||||
.add(model::object::Column::Id.is_not_null())
|
||||
)
|
||||
.order_by(model::activity::Column::Internal, Order::Desc)
|
||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
||||
.order_by(model::activity::Column::Internal, Order::Desc)
|
||||
.select_only();
|
||||
|
||||
for col in model::activity::Column::iter() {
|
||||
|
@ -44,11 +47,10 @@ impl Query {
|
|||
|
||||
pub fn objects(my_id: Option<i64>) -> Select<model::addressing::Entity> {
|
||||
let mut select = model::addressing::Entity::find()
|
||||
// .distinct_on([
|
||||
// (model::object::Entity, model::object::Column::Internal).into_column_ref(),
|
||||
// (model::addressing::Entity, model::addressing::Column::Published).into_column_ref(),
|
||||
// ])
|
||||
.distinct()
|
||||
.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::addressing::Relation::Objects.def())
|
||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
||||
.order_by(model::object::Column::Internal, Order::Desc)
|
||||
|
|
Loading…
Reference in a new issue