fix: order context and replies

This commit is contained in:
əlemi 2024-12-26 17:18:26 +01:00
parent 35776558f1
commit 81f299f3d4
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 4 additions and 3 deletions

View file

@ -1,5 +1,5 @@
use axum::extract::{Path, Query, State}; use axum::extract::{Path, Query, State};
use sea_orm::{ColumnTrait, Order, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect}; use sea_orm::{ColumnTrait, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model, selector::{BatchFillable, RichObject}, Context}; use upub::{model, selector::{BatchFillable, RichObject}, Context};
use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity}; use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity};
@ -33,7 +33,7 @@ pub async fn page(
.filter(auth.filter_objects()) .filter(auth.filter_objects())
.filter(model::object::Column::Context.eq(context)) .filter(model::object::Column::Context.eq(context))
// note that this should be ASC so we get replies somewhat ordered // note that this should be ASC so we get replies somewhat ordered
.order_by(model::object::Column::Published, Order::Asc) .order_by_asc(model::object::Column::Published)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.into_model::<RichObject>() .into_model::<RichObject>()

View file

@ -1,6 +1,6 @@
use apb::{BaseMut, CollectionMut, LD}; use apb::{BaseMut, CollectionMut, LD};
use axum::extract::{Path, Query, State}; use axum::extract::{Path, Query, State};
use sea_orm::{ColumnTrait, PaginatorTrait, QueryFilter, QuerySelect}; use sea_orm::{ColumnTrait, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model, selector::RichObject, traits::Fetcher, Context}; use upub::{model, selector::RichObject, traits::Fetcher, Context};
use crate::{activitypub::{Pagination, TryFetch}, builders::JsonLD, AuthIdentity}; use crate::{activitypub::{Pagination, TryFetch}, builders::JsonLD, AuthIdentity};
@ -55,6 +55,7 @@ pub async fn page(
.offset(offset) .offset(offset)
.filter(auth.filter_objects()) .filter(auth.filter_objects())
.filter(model::object::Column::InReplyTo.eq(oid)) .filter(model::object::Column::InReplyTo.eq(oid))
.order_by_desc(model::object::Column::Published)
.into_model::<RichObject>() .into_model::<RichObject>()
.all(ctx.db()) .all(ctx.db())
.await? .await?