forked from alemi/upub
feat: order by publish date, not discovery
also centralized ordering inside select_* queries
This commit is contained in:
parent
870e46ba31
commit
f2f7b51fdc
8 changed files with 6 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
use apb::{ActivityMut, ObjectMut};
|
use apb::{ActivityMut, ObjectMut};
|
||||||
use sea_orm::{entity::prelude::*, FromQueryResult, Iterable, QuerySelect, SelectColumns};
|
use sea_orm::{entity::prelude::*, FromQueryResult, Iterable, Order, QueryOrder, QuerySelect, SelectColumns};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
#[sea_orm(table_name = "addressing")]
|
#[sea_orm(table_name = "addressing")]
|
||||||
|
@ -137,7 +137,8 @@ impl Entity {
|
||||||
.distinct()
|
.distinct()
|
||||||
.select_only()
|
.select_only()
|
||||||
.join(sea_orm::JoinType::InnerJoin, Relation::Activity.def())
|
.join(sea_orm::JoinType::InnerJoin, Relation::Activity.def())
|
||||||
.join(sea_orm::JoinType::LeftJoin, crate::model::activity::Relation::Object.def());
|
.join(sea_orm::JoinType::LeftJoin, crate::model::activity::Relation::Object.def())
|
||||||
|
.order_by(crate::model::activity::Column::Published, Order::Desc);
|
||||||
|
|
||||||
for col in crate::model::activity::Column::iter() {
|
for col in crate::model::activity::Column::iter() {
|
||||||
select = select.select_column_as(col, format!("{}{}", crate::model::activity::Entity.table_name(), col.to_string()));
|
select = select.select_column_as(col, format!("{}{}", crate::model::activity::Entity.table_name(), col.to_string()));
|
||||||
|
@ -155,7 +156,8 @@ impl Entity {
|
||||||
.distinct()
|
.distinct()
|
||||||
.select_only()
|
.select_only()
|
||||||
.join(sea_orm::JoinType::InnerJoin, Relation::Object.def())
|
.join(sea_orm::JoinType::InnerJoin, Relation::Object.def())
|
||||||
.join(sea_orm::JoinType::LeftJoin, crate::model::object::Relation::Activity.def());
|
.join(sea_orm::JoinType::LeftJoin, crate::model::object::Relation::Activity.def())
|
||||||
|
.order_by(crate::model::object::Column::Published, Order::Desc);
|
||||||
|
|
||||||
for col in crate::model::object::Column::iter() {
|
for col in crate::model::object::Column::iter() {
|
||||||
select = select.select_column_as(col, format!("{}{}", crate::model::object::Entity.table_name(), col.to_string()));
|
select = select.select_column_as(col, format!("{}{}", crate::model::object::Entity.table_name(), col.to_string()));
|
||||||
|
|
|
@ -43,7 +43,6 @@ pub async fn page(
|
||||||
let items = model::addressing::Entity::find_objects()
|
let items = model::addressing::Entity::find_objects()
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition())
|
||||||
.filter(model::object::Column::Context.eq(context))
|
.filter(model::object::Column::Context.eq(context))
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.into_model::<WrappedObject>()
|
.into_model::<WrappedObject>()
|
||||||
|
|
|
@ -22,7 +22,6 @@ pub async fn page(
|
||||||
let offset = page.offset.unwrap_or(0);
|
let offset = page.offset.unwrap_or(0);
|
||||||
let activities = model::addressing::Entity::find_activities()
|
let activities = model::addressing::Entity::find_activities()
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition())
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.into_model::<EmbeddedActivity>()
|
.into_model::<EmbeddedActivity>()
|
||||||
|
|
|
@ -42,7 +42,6 @@ pub async fn page(
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition())
|
||||||
.filter(model::object::Column::InReplyTo.eq(oid))
|
.filter(model::object::Column::InReplyTo.eq(oid))
|
||||||
// TODO also limit to only local activities
|
// TODO also limit to only local activities
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.into_model::<WrappedObject>()
|
.into_model::<WrappedObject>()
|
||||||
|
|
|
@ -18,7 +18,6 @@ pub async fn page(
|
||||||
let items = model::addressing::Entity::find_activities()
|
let items = model::addressing::Entity::find_activities()
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition())
|
||||||
// TODO also limit to only local activities
|
// TODO also limit to only local activities
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.into_model::<EmbeddedActivity>()
|
.into_model::<EmbeddedActivity>()
|
||||||
|
|
|
@ -36,7 +36,6 @@ pub async fn page(
|
||||||
let offset = page.offset.unwrap_or(0);
|
let offset = page.offset.unwrap_or(0);
|
||||||
let activities = model::addressing::Entity::find_activities()
|
let activities = model::addressing::Entity::find_activities()
|
||||||
.filter(model::addressing::Column::Actor.eq(&uid))
|
.filter(model::addressing::Column::Actor.eq(&uid))
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.into_model::<EmbeddedActivity>()
|
.into_model::<EmbeddedActivity>()
|
||||||
|
|
|
@ -30,7 +30,6 @@ pub async fn page(
|
||||||
let activities = model::addressing::Entity::find_activities()
|
let activities = model::addressing::Entity::find_activities()
|
||||||
.filter(model::activity::Column::Actor.eq(&uid))
|
.filter(model::activity::Column::Actor.eq(&uid))
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition())
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc)
|
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.into_model::<EmbeddedActivity>()
|
.into_model::<EmbeddedActivity>()
|
||||||
|
|
|
@ -72,8 +72,7 @@ pub async fn statuses(
|
||||||
let uid = ctx.uid(id);
|
let uid = ctx.uid(id);
|
||||||
model::addressing::Entity::find_activities()
|
model::addressing::Entity::find_activities()
|
||||||
.filter(model::activity::Column::Actor.eq(uid))
|
.filter(model::activity::Column::Actor.eq(uid))
|
||||||
.filter(auth.filter_condition())
|
.filter(auth.filter_condition());
|
||||||
.order_by(model::addressing::Column::Published, Order::Desc);
|
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue