fix: feed should specify ordering, context by old

This commit is contained in:
əlemi 2024-12-27 15:36:42 +01:00
parent edbf381b31
commit 2bd7682c7e
Signed by: alemi
GPG key ID: A4895B84D311642C
8 changed files with 20 additions and 10 deletions

View file

@ -18,8 +18,6 @@ impl Query {
.add(model::activity::Column::Id.is_not_null()) .add(model::activity::Column::Id.is_not_null())
.add(model::object::Column::Id.is_not_null()) .add(model::object::Column::Id.is_not_null())
) )
.order_by(model::addressing::Column::Published, Order::Desc)
.order_by(model::activity::Column::Internal, Order::Desc)
.select_only(); .select_only();
for col in model::activity::Column::iter() { for col in model::activity::Column::iter() {

View file

@ -1,5 +1,5 @@
use axum::{http::StatusCode, extract::{Path, Query, State}, Json}; use axum::{http::StatusCode, extract::{Path, Query, State}, Json};
use sea_orm::{ColumnTrait, Condition, QueryFilter, QuerySelect}; use sea_orm::{ColumnTrait, Condition, QueryFilter, QueryOrder, QuerySelect};
use upub::{selector::{RichActivity, RichFillable}, Context}; use upub::{selector::{RichActivity, RichFillable}, Context};
@ -45,6 +45,8 @@ pub async fn page(
.filter(filter) .filter(filter)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichActivity>() .into_model::<RichActivity>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

View file

@ -1,5 +1,5 @@
use axum::{extract::{Path, Query, State}, http::StatusCode, Json}; use axum::{extract::{Path, Query, State}, http::StatusCode, Json};
use sea_orm::{ActiveValue::{NotSet, Set}, ColumnTrait, Condition, EntityTrait, QueryFilter, QuerySelect}; use sea_orm::{ActiveValue::{NotSet, Set}, ColumnTrait, Condition, EntityTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model, selector::{RichActivity, RichFillable}, Context}; use upub::{model, selector::{RichActivity, RichFillable}, Context};
@ -32,9 +32,10 @@ pub async fn page(
// by default we want replies because servers don't know about our api and need to see everything // by default we want replies because servers don't know about our api and need to see everything
let items = upub::Query::feed(auth.my_id(), page.replies.unwrap_or(true)) let items = upub::Query::feed(auth.my_id(), page.replies.unwrap_or(true))
.filter(filter) .filter(filter)
// TODO also limit to only local activities
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichActivity>() .into_model::<RichActivity>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

View file

@ -1,7 +1,7 @@
use apb::{LD, ActorMut, BaseMut, ObjectMut, PublicKeyMut}; use apb::{LD, ActorMut, BaseMut, ObjectMut, PublicKeyMut};
use axum::{extract::{Path, Query, State}, http::HeaderMap, response::{IntoResponse, Redirect, Response}}; use axum::{extract::{Path, Query, State}, http::HeaderMap, response::{IntoResponse, Redirect, Response}};
use reqwest::Method; use reqwest::Method;
use sea_orm::{ColumnTrait, Condition, QueryFilter, QuerySelect}; use sea_orm::{ColumnTrait, Condition, QueryFilter, QueryOrder, QuerySelect};
use upub::{selector::{RichFillable, RichObject}, traits::{Cloaker, Fetcher}, Context}; use upub::{selector::{RichFillable, RichObject}, traits::{Cloaker, Fetcher}, Context};
use crate::{builders::JsonLD, ApiError, AuthIdentity}; use crate::{builders::JsonLD, ApiError, AuthIdentity};
@ -69,6 +69,8 @@ pub async fn search(
.filter(filter) .filter(filter)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichObject>() .into_model::<RichObject>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

View file

@ -1,6 +1,6 @@
use apb::{Activity, ActivityType, Base}; use apb::{Activity, ActivityType, Base};
use axum::{extract::{Query, State}, http::StatusCode, Json}; use axum::{extract::{Query, State}, http::StatusCode, Json};
use sea_orm::{sea_query::IntoCondition, ActiveValue::{NotSet, Set}, ColumnTrait, EntityTrait, QueryFilter, QuerySelect}; use sea_orm::{sea_query::IntoCondition, ActiveValue::{NotSet, Set}, ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model::job::JobType, selector::{RichActivity, RichFillable}, Context}; use upub::{model::job::JobType, selector::{RichActivity, RichFillable}, Context};
use crate::{AuthIdentity, Identity, builders::JsonLD}; use crate::{AuthIdentity, Identity, builders::JsonLD};
@ -25,6 +25,8 @@ pub async fn page(
.filter(filter) .filter(filter)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichActivity>() .into_model::<RichActivity>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

View file

@ -1,5 +1,5 @@
use axum::extract::{Path, Query, State}; use axum::extract::{Path, Query, State};
use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter, QuerySelect}; use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model, selector::{RichFillable, RichObject}, Context}; use upub::{model, selector::{RichFillable, RichObject}, Context};
use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity}; use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity};
@ -39,6 +39,8 @@ pub async fn page(
.filter(filter) .filter(filter)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_asc(upub::model::addressing::Column::Published)
.order_by_asc(upub::model::activity::Column::Internal)
.into_model::<RichObject>() .into_model::<RichObject>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

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, Condition, PaginatorTrait, QueryFilter, QuerySelect}; use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
use upub::{model, selector::{RichFillable, RichObject}, traits::Fetcher, Context}; use upub::{model, selector::{RichFillable, RichObject}, traits::Fetcher, Context};
use crate::{activitypub::{Pagination, TryFetch}, builders::JsonLD, AuthIdentity}; use crate::{activitypub::{Pagination, TryFetch}, builders::JsonLD, AuthIdentity};
@ -55,9 +55,10 @@ pub async fn page(
let (limit, offset) = page.pagination(); let (limit, offset) = page.pagination();
let items = upub::Query::feed(auth.my_id(), page.replies.unwrap_or(true)) let items = upub::Query::feed(auth.my_id(), page.replies.unwrap_or(true))
.filter(filter) .filter(filter)
// TODO also limit to only local activities
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichObject>() .into_model::<RichObject>()
.all(ctx.db()) .all(ctx.db())
.await? .await?

View file

@ -23,6 +23,8 @@ pub async fn page(
.filter(filter) .filter(filter)
.limit(limit) .limit(limit)
.offset(offset) .offset(offset)
.order_by_desc(upub::model::addressing::Column::Published)
.order_by_desc(upub::model::activity::Column::Internal)
.into_model::<RichActivity>() .into_model::<RichActivity>()
.all(ctx.db()) .all(ctx.db())
.await? .await?