Fix errors

This commit is contained in:
dullbananas 2023-08-02 12:56:59 -07:00 committed by GitHub
parent 4e3829facc
commit c9102c14f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 38 additions and 32 deletions

View file

@ -8,6 +8,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -30,7 +31,7 @@ use lemmy_db_schema::{
comment::CommentWithoutId,
comment_report::CommentReport,
community::CommunityWithoutId,
person::PersonWithoutId,
person::{Person, PersonWithoutId},
post::PostWithoutId,
},
traits::JoinView,
@ -70,12 +71,12 @@ fn queries<'a>() -> Queries<
PostWithoutId::as_select(),
CommunityWithoutId::as_select(),
PersonWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
CommentAggregatesNotInComment::as_select(),
community_person_ban::id.nullable().is_not_null(),
comment_like::score.nullable(),
aliases::person2
.fields(PersonWithoutId::as_select())
.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection())
.nullable(),
);
@ -250,6 +251,7 @@ impl JoinView for CommentReportView {
resolver,
): Self::JoinTuple,
) -> Self {
let comment = comment.into_full(comment_report.comment_id);
Self {
resolver: resolver
.zip(comment_report.resolver_id)
@ -261,7 +263,7 @@ impl JoinView for CommentReportView {
creator: creator.into_full(comment_report.creator_id),
community: community.into_full(post.community_id),
post: post.into_full(comment.post_id),
comment: comment.into_full(comment_report.comment_id),
comment,
comment_report,
}
}

View file

@ -364,10 +364,7 @@ mod tests {
CommentQuery,
CommentSortType,
CommentView,
Community,
DbPool,
Person,
Post,
},
structs::LocalUserView,
};
@ -378,13 +375,13 @@ mod tests {
source::{
actor_language::LocalUserLanguage,
comment::{CommentInsertForm, CommentLike, CommentLikeForm},
community::CommunityInsertForm,
community::{Community, CommunityInsertForm},
instance::Instance,
language::Language,
local_user::{LocalUser, LocalUserInsertForm},
person::PersonInsertForm,
person::{Person, PersonInsertForm},
person_block::{PersonBlock, PersonBlockForm},
post::PostInsertForm,
post::{Post, PostInsertForm},
},
traits::{Blockable, Crud, Likeable},
utils::build_db_pool_for_tests,

View file

@ -11,7 +11,7 @@ use std::collections::HashMap;
type CustomEmojiTuple = (CustomEmoji, Option<KeywordTuple>);
type KeywordTuple = (CustomEmojiId, String);
type KeywordTuple = (i32, String);
impl CustomEmojiView {
pub async fn get(pool: &mut DbPool<'_>, emoji_id: CustomEmojiId) -> Result<Self, Error> {

View file

@ -115,7 +115,7 @@ impl LocalUserView {
impl JoinView for LocalUserView {
type JoinTuple = LocalUserViewTuple;
fn from_tuple((loal_user, person, counts): Self::JoinTuple) -> Self {
fn from_tuple((local_user, person, counts): Self::JoinTuple) -> Self {
Self {
person: person.into_full(local_user.person_id),
local_user,

View file

@ -7,6 +7,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -26,7 +27,7 @@ use lemmy_db_schema::{
},
source::{
community::CommunityWithoutId,
person::PersonWithoutId,
person::{Person, PersonWithoutId},
post::PostWithoutId,
post_report::PostReport,
},
@ -80,11 +81,11 @@ fn queries<'a>() -> Queries<
PostWithoutId::as_select(),
CommunityWithoutId::as_select(),
PersonWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
community_person_ban::id.nullable().is_not_null(),
post_like::score.nullable(),
PostAggregatesNotInPost::as_select(),
aliases::person2.fields(PersonWithoutId::as_select.nullable()),
aliases::person2.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection().nullable()),
))
};
@ -220,9 +221,9 @@ impl JoinView for PostReportView {
resolver,
): Self::JoinTuple,
) -> Self {
let post = post.into_full(post_report.post_id);
Self {
resolver: (resolver, post_report.resolver_id)
.zip()
resolver: Option::zip(resolver, post_report.resolver_id)
.map(|(resolver, id)| resolver.into_full(id)),
counts: counts.into_full(&post),
my_vote,
@ -230,7 +231,7 @@ impl JoinView for PostReportView {
post_creator: post_creator.into_full(post.creator_id),
creator: creator.into_full(post_report.creator_id),
community: community.into_full(post.community_id),
post: post.into_full(post_report.post_id),
post,
post_report,
}
}

View file

@ -453,7 +453,6 @@ impl JoinView for PostView {
unread_comments,
): Self::JoinTuple,
) -> Self {
let counts = a.4.into_full(&a.0);
Self {
creator: creator.into_full(post.creator_id),
community: community.into_full(post.community_id),

View file

@ -6,6 +6,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -50,9 +51,9 @@ fn queries<'a>() -> Queries<
private_message_report::all_columns,
PrivateMessageWithoutId::as_select(),
PersonWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
aliases::person2
.fields(PersonWithoutId::as_select())
.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection())
.nullable(),
))
};
@ -134,8 +135,7 @@ impl JoinView for PrivateMessageReportView {
): Self::JoinTuple,
) -> Self {
Self {
resolver: (resolver, private_message_report.resolver_id)
.zip()
resolver: Option::zip(resolver, private_message_report.resolver_id)
.map(|(resolver, id)| resolver.into_full(id)),
creator: creator.into_full(private_message_report.creator_id),
private_message_creator: private_message_creator.into_full(private_message.creator_id),

View file

@ -7,6 +7,7 @@ use diesel::{
ExpressionMethods,
JoinOnDsl,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -37,7 +38,7 @@ fn queries<'a>() -> Queries<
let selection = (
private_message::all_columns,
PersonWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
);
let read = move |mut conn: DbConn<'a>, private_message_id: PrivateMessageId| async move {

View file

@ -7,6 +7,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -47,7 +48,7 @@ fn queries<'a>() -> Queries<
LocalUserWithoutId::as_select(),
PersonWithoutId::as_select(),
aliases::person1
.fields(PersonWithoutId::as_select())
.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection())
.nullable(),
))
};
@ -148,7 +149,8 @@ impl JoinView for RegistrationApplicationView {
(registration_application, creator_local_user, creator, admin): Self::JoinTuple,
) -> Self {
Self {
admin: admin.into_full(registration_application.admin_id),
admin: Option::zip(admin, registration_application.admin_id)
.map(|admin, id| admin.into_full(id)),
creator: creator.into_full(creator_local_user.person_id),
creator_local_user: creator_local_user.into_full(registration_application.local_user_id),
registration_application,

View file

@ -1,5 +1,5 @@
use crate::structs::SiteView;
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl};
use diesel::{result::Error, ExpressionMethods, JoinOnDsl, QueryDsl, SelectableHelper};
use diesel_async::RunQueryDsl;
use lemmy_db_schema::{
aggregates::structs::SiteAggregates,
@ -23,7 +23,7 @@ impl SiteView {
local_site_rate_limit::all_columns,
site_aggregates::all_columns,
))
.first::<(Site, LocalSite, LocalSiteRateLimit, SiteAggregates)>(conn)
.first::<(SiteWithoutId, LocalSite, LocalSiteRateLimit, SiteAggregates)>(conn)
.await?;
site.private_key = None;

View file

@ -7,6 +7,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -111,7 +112,7 @@ fn queries<'a>() -> Queries<
PersonWithoutId::as_select(),
PostWithoutId::as_select(),
CommunityWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
CommentAggregatesNotInComment::as_select(),
community_person_ban::id.nullable().is_not_null(),
CommunityFollower::select_subscribed_type(),
@ -234,13 +235,14 @@ impl JoinView for CommentReplyView {
my_vote,
): Self::JoinTuple,
) -> Self {
let comment = comment.into_full(comment.into_full(comment_reply.comment_id));
Self {
counts: counts.into_full(&comment),
recipient: recipient.into_full(comment_reply.recipient_id),
community: community.into_full(post.community_id),
post: post.into_full(comment.post_id),
creator: creator.into_full(comment.creator_id),
comment: comment.into_full(comment_reply.comment_id),
comment,
comment_reply,
creator_banned_from_community,
subscribed,

View file

@ -8,6 +8,7 @@ use diesel::{
JoinOnDsl,
NullableExpressionMethods,
QueryDsl,
Selectable,
SelectableHelper,
};
use diesel_async::RunQueryDsl;
@ -107,7 +108,7 @@ fn queries<'a>() -> Queries<
PersonWithoutId::as_select(),
PostWithoutId::as_select(),
CommunityWithoutId::as_select(),
aliases::person1.fields(PersonWithoutId::as_select()),
aliases::person1.fields(<PersonWithoutId as Selectable<Pg>>::construct_selection()),
CommentAggregatesNotInComment::as_select(),
community_person_ban::id.nullable().is_not_null(),
CommunityFollower::select_subscribed_type(),
@ -251,13 +252,14 @@ impl JoinView for PersonMentionView {
my_vote,
): Self::JoinTuple,
) -> Self {
let comment = comment.into_full(person_mention.comment_id),
Self {
counts: counts.into_full(&comment),
recipient: recipient.into_full(person_mention.recipient_id),
community: community.into_full(post.community_id),
post: post.into_full(comment.post_id),
creator: creator.into_full(comment.creator_id),
comment: comment.into_full(person_mention.comment_id),
comment,
person_mention,
creator_banned_from_community,
subscribed,