Resolve avatar and banner separately
ci/woodpecker/push/ociImagePush Pipeline is running Details

This commit is contained in:
Natty 2024-01-15 18:14:35 +01:00
parent 185262eb05
commit b9f0f33b3c
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
5 changed files with 33 additions and 19 deletions

View File

@ -6,8 +6,9 @@ use sea_orm::{
Condition, EntityTrait, Iden, JoinType, QueryFilter, QueryOrder, QuerySelect, QueryTrait,
Select,
};
use std::sync::Arc;
use ck::{note, note_reaction, user, user_note_pining};
use ck::{note, note_reaction, user_note_pining};
use data::{sub_interaction_reaction, sub_interaction_renote, NoteData};
use magnetar_sdk::types::SpanFilter;
@ -35,9 +36,10 @@ pub trait NoteVisibilityFilterFactory: Send + Sync {
fn with_note_and_user_tables(&self, note: &dyn Iden) -> SimpleExpr;
}
#[derive(Clone)]
pub struct NoteResolveOptions {
pub ids: Option<Vec<String>>,
pub visibility_filter: Box<dyn NoteVisibilityFilterFactory>,
pub visibility_filter: Arc<dyn NoteVisibilityFilterFactory>,
pub time_range: Option<SpanFilter>,
pub limit: Option<u64>,
pub with_reply_target: bool,
@ -221,7 +223,6 @@ impl NoteResolver {
// Add the note's author
let user_tbl = note_tbl.join_str(USER);
q.add_aliased_columns::<user::Entity>(&user_tbl);
q.join_columns(
JoinType::LeftJoin,
note::Relation::User.with_from_alias(note_tbl),

View File

@ -106,8 +106,10 @@ impl ModelPagination for UserFollowRequestData {
}
}
#[derive(Clone)]
pub struct UserResolveOptions {
pub with_avatar_and_banner: bool,
pub with_avatar: bool,
pub with_banner: bool,
pub with_profile: bool,
}
@ -130,7 +132,8 @@ impl UserResolver {
q: &mut SelectStatement,
user_tbl: &MagIden,
UserResolveOptions {
with_avatar_and_banner,
with_avatar,
with_banner,
with_profile,
}: &UserResolveOptions,
) {
@ -148,19 +151,24 @@ impl UserResolver {
);
}
if *with_avatar_and_banner {
if *with_avatar {
let avatar_tbl = user_tbl.join_str(AVATAR);
let banner_tbl = user_tbl.join_str(BANNER);
q.add_aliased_columns::<drive_file::Entity>(&avatar_tbl)
.add_aliased_columns::<drive_file::Entity>(&banner_tbl);
q.add_aliased_columns::<drive_file::Entity>(&avatar_tbl);
q.join_columns(
JoinType::LeftJoin,
user::Relation::DriveFile2.with_from_alias(user_tbl),
&avatar_tbl,
)
.join_columns(
);
}
if *with_banner {
let banner_tbl = user_tbl.join_str(BANNER);
q.add_aliased_columns::<drive_file::Entity>(&banner_tbl);
q.join_columns(
JoinType::LeftJoin,
user::Relation::DriveFile1.with_from_alias(user_tbl),
&banner_tbl,

View File

@ -574,13 +574,14 @@ impl NoteModel {
let Some(note) = note_resolver
.get_one(&NoteResolveOptions {
ids: Some(vec![id.to_owned()]),
visibility_filter: Box::new(NoteVisibilityFilterModel.new_note_visibility_filter(
visibility_filter: Arc::new(NoteVisibilityFilterModel.new_note_visibility_filter(
ctx.self_user.as_deref().map(ck::user::Model::get_id),
)),
time_range: None,
limit: None,
user_options: UserResolveOptions {
with_avatar_and_banner: self.with_context,
with_avatar: self.with_context,
with_banner: false,
with_profile: false,
},
with_reply_target: self.with_context,
@ -613,13 +614,14 @@ impl NoteModel {
let notes = note_resolver
.get_many(&NoteResolveOptions {
ids: None,
visibility_filter: Box::new(NoteVisibilityFilterModel.new_note_visibility_filter(
visibility_filter: Arc::new(NoteVisibilityFilterModel.new_note_visibility_filter(
ctx.self_user.as_deref().map(ck::user::Model::get_id),
)),
time_range: None,
limit: None,
user_options: UserResolveOptions {
with_avatar_and_banner: self.with_context,
with_avatar: self.with_context,
with_banner: false,
with_profile: false,
},
with_reply_target: self.with_context,

View File

@ -596,7 +596,8 @@ impl UserModel {
.get_user_resolver()
.get_followers(
&UserResolveOptions {
with_avatar_and_banner: true,
with_avatar: true,
with_banner: true,
with_profile: true,
},
id,
@ -641,7 +642,8 @@ impl UserModel {
.get_user_resolver()
.get_followees(
&UserResolveOptions {
with_avatar_and_banner: true,
with_avatar: true,
with_banner: true,
with_profile: true,
},
id,
@ -684,7 +686,8 @@ impl UserModel {
.get_user_resolver()
.get_follow_requests(
&UserResolveOptions {
with_avatar_and_banner: true,
with_avatar: true,
with_banner: true,
with_profile: true,
},
id,

View File

@ -12,7 +12,7 @@ use either::Either;
use itertools::Itertools;
use magnetar_calckey_model::sea_orm::prelude::async_trait::async_trait;
use magnetar_core::web_model::rel::{RelNext, RelPrev};
use magnetar_sdk::types::{NoFilter, PaginationShape, SpanFilter};
use magnetar_sdk::types::{PaginationShape, SpanFilter};
use magnetar_sdk::util_types::U64Range;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;