feat: order by publish date, not discovery

also centralized ordering inside select_* queries
This commit is contained in:
əlemi 2024-04-22 02:49:04 +02:00
parent 870e46ba31
commit f2f7b51fdc
Signed by: alemi
GPG key ID: A4895B84D311642C
8 changed files with 6 additions and 11 deletions

View file

@ -1,5 +1,5 @@
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)]
#[sea_orm(table_name = "addressing")]
@ -137,7 +137,8 @@ impl Entity {
.distinct()
.select_only()
.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() {
select = select.select_column_as(col, format!("{}{}", crate::model::activity::Entity.table_name(), col.to_string()));
@ -155,7 +156,8 @@ impl Entity {
.distinct()
.select_only()
.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() {
select = select.select_column_as(col, format!("{}{}", crate::model::object::Entity.table_name(), col.to_string()));

View file

@ -43,7 +43,6 @@ pub async fn page(
let items = model::addressing::Entity::find_objects()
.filter(auth.filter_condition())
.filter(model::object::Column::Context.eq(context))
.order_by(model::addressing::Column::Published, Order::Desc)
.limit(limit)
.offset(offset)
.into_model::<WrappedObject>()

View file

@ -22,7 +22,6 @@ pub async fn page(
let offset = page.offset.unwrap_or(0);
let activities = model::addressing::Entity::find_activities()
.filter(auth.filter_condition())
.order_by(model::addressing::Column::Published, Order::Desc)
.limit(limit)
.offset(offset)
.into_model::<EmbeddedActivity>()

View file

@ -42,7 +42,6 @@ pub async fn page(
.filter(auth.filter_condition())
.filter(model::object::Column::InReplyTo.eq(oid))
// TODO also limit to only local activities
.order_by(model::addressing::Column::Published, Order::Desc)
.limit(limit)
.offset(offset)
.into_model::<WrappedObject>()

View file

@ -18,7 +18,6 @@ pub async fn page(
let items = model::addressing::Entity::find_activities()
.filter(auth.filter_condition())
// TODO also limit to only local activities
.order_by(model::addressing::Column::Published, Order::Desc)
.limit(limit)
.offset(offset)
.into_model::<EmbeddedActivity>()

View file

@ -36,7 +36,6 @@ pub async fn page(
let offset = page.offset.unwrap_or(0);
let activities = model::addressing::Entity::find_activities()
.filter(model::addressing::Column::Actor.eq(&uid))
.order_by(model::addressing::Column::Published, Order::Desc)
.offset(offset)
.limit(limit)
.into_model::<EmbeddedActivity>()

View file

@ -30,7 +30,6 @@ pub async fn page(
let activities = model::addressing::Entity::find_activities()
.filter(model::activity::Column::Actor.eq(&uid))
.filter(auth.filter_condition())
.order_by(model::addressing::Column::Published, Order::Desc)
.limit(limit)
.offset(offset)
.into_model::<EmbeddedActivity>()

View file

@ -72,8 +72,7 @@ pub async fn statuses(
let uid = ctx.uid(id);
model::addressing::Entity::find_activities()
.filter(model::activity::Column::Actor.eq(uid))
.filter(auth.filter_condition())
.order_by(model::addressing::Column::Published, Order::Desc);
.filter(auth.filter_condition());
todo!()
}