mirror of https://github.com/LemmyNet/lemmy.git
Replace some nullable parts of selection with id::nullable().is_not_null()
parent
79a6bf003e
commit
2f3f6bb3c9
|
@ -29,7 +29,7 @@ use lemmy_db_schema::{
|
|||
source::{
|
||||
comment::Comment,
|
||||
comment_report::CommentReport,
|
||||
community::{Community, CommunityPersonBan},
|
||||
community::Community,
|
||||
person::Person,
|
||||
post::Post,
|
||||
},
|
||||
|
@ -72,7 +72,7 @@ fn queries<'a>() -> Queries<
|
|||
person::all_columns,
|
||||
aliases::person1.fields(person::all_columns),
|
||||
CommentAggregatesNotInComment::as_select(),
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
comment_like::score.nullable(),
|
||||
aliases::person2.fields(person::all_columns).nullable(),
|
||||
);
|
||||
|
@ -229,7 +229,7 @@ impl JoinView for CommentReportView {
|
|||
Person,
|
||||
Person,
|
||||
CommentAggregatesNotInComment,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
Option<i16>,
|
||||
Option<Person>,
|
||||
);
|
||||
|
@ -244,7 +244,7 @@ impl JoinView for CommentReportView {
|
|||
creator: a.4,
|
||||
comment_creator: a.5,
|
||||
counts,
|
||||
creator_banned_from_community: a.7.is_some(),
|
||||
creator_banned_from_community: a.7,
|
||||
my_vote: a.8,
|
||||
resolver: a.9,
|
||||
}
|
||||
|
|
|
@ -30,10 +30,9 @@ use lemmy_db_schema::{
|
|||
post,
|
||||
},
|
||||
source::{
|
||||
comment::{Comment, CommentSaved},
|
||||
community::{Community, CommunityFollower, CommunityPersonBan},
|
||||
comment::Comment,
|
||||
community::{Community, CommunityFollower},
|
||||
person::Person,
|
||||
person_block::PersonBlock,
|
||||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
|
@ -48,10 +47,10 @@ type CommentViewTuple = (
|
|||
Post,
|
||||
Community,
|
||||
CommentAggregatesNotInComment,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
Option<CommunityFollower>,
|
||||
Option<CommentSaved>,
|
||||
Option<PersonBlock>,
|
||||
bool,
|
||||
bool,
|
||||
Option<i16>,
|
||||
);
|
||||
|
||||
|
@ -110,10 +109,10 @@ fn queries<'a>() -> Queries<
|
|||
post::all_columns,
|
||||
community::all_columns,
|
||||
CommentAggregatesNotInComment::as_select(),
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
community_follower::all_columns.nullable(),
|
||||
comment_saved::all_columns.nullable(),
|
||||
person_block::all_columns.nullable(),
|
||||
comment_saved::id.nullable().is_not_null(),
|
||||
person_block::id.nullable().is_not_null(),
|
||||
comment_like::score.nullable(),
|
||||
);
|
||||
|
||||
|
@ -334,10 +333,10 @@ impl JoinView for CommentView {
|
|||
post: a.2,
|
||||
community: a.3,
|
||||
counts,
|
||||
creator_banned_from_community: a.5.is_some(),
|
||||
creator_banned_from_community: a.5,
|
||||
subscribed: CommunityFollower::to_subscribed_type(&a.6),
|
||||
saved: a.7.is_some(),
|
||||
creator_blocked: a.8.is_some(),
|
||||
saved: a.7,
|
||||
creator_blocked: a.8,
|
||||
my_vote: a.9,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,7 @@ use lemmy_db_schema::{
|
|||
post_like,
|
||||
post_report,
|
||||
},
|
||||
source::{
|
||||
community::{Community, CommunityPersonBan},
|
||||
person::Person,
|
||||
post::Post,
|
||||
post_report::PostReport,
|
||||
},
|
||||
source::{community::Community, person::Person, post::Post, post_report::PostReport},
|
||||
traits::JoinView,
|
||||
utils::{get_conn, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||
};
|
||||
|
@ -40,7 +35,7 @@ type PostReportViewTuple = (
|
|||
Community,
|
||||
Person,
|
||||
Person,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
Option<i16>,
|
||||
PostAggregatesNotInPost,
|
||||
Option<Person>,
|
||||
|
@ -81,7 +76,7 @@ fn queries<'a>() -> Queries<
|
|||
community::all_columns,
|
||||
person::all_columns,
|
||||
aliases::person1.fields(person::all_columns),
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
post_like::score.nullable(),
|
||||
PostAggregatesNotInPost::as_select(),
|
||||
aliases::person2.fields(person::all_columns.nullable()),
|
||||
|
@ -215,7 +210,7 @@ impl JoinView for PostReportView {
|
|||
community: a.2,
|
||||
creator: a.3,
|
||||
post_creator: a.4,
|
||||
creator_banned_from_community: a.5.is_some(),
|
||||
creator_banned_from_community: a.5,
|
||||
my_vote: a.6,
|
||||
counts,
|
||||
resolver: a.8,
|
||||
|
|
|
@ -35,10 +35,9 @@ use lemmy_db_schema::{
|
|||
post_saved,
|
||||
},
|
||||
source::{
|
||||
community::{Community, CommunityFollower, CommunityPersonBan},
|
||||
community::{Community, CommunityFollower},
|
||||
person::Person,
|
||||
person_block::PersonBlock,
|
||||
post::{Post, PostRead, PostSaved},
|
||||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
utils::{fuzzy_search, limit_and_offset, DbConn, DbPool, ListFn, Queries, ReadFn},
|
||||
|
@ -51,12 +50,12 @@ type PostViewTuple = (
|
|||
Post,
|
||||
Person,
|
||||
Community,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
PostAggregatesNotInPost,
|
||||
Option<CommunityFollower>,
|
||||
Option<PostSaved>,
|
||||
Option<PostRead>,
|
||||
Option<PersonBlock>,
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
Option<i16>,
|
||||
i64,
|
||||
);
|
||||
|
@ -137,12 +136,12 @@ fn queries<'a>() -> Queries<
|
|||
post::all_columns,
|
||||
person::all_columns,
|
||||
community::all_columns,
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
PostAggregatesNotInPost::as_select(),
|
||||
community_follower::all_columns.nullable(),
|
||||
post_saved::all_columns.nullable(),
|
||||
post_read::all_columns.nullable(),
|
||||
person_block::all_columns.nullable(),
|
||||
post_saved::id.nullable().is_not_null(),
|
||||
post_read::id.nullable().is_not_null(),
|
||||
person_block::id.nullable().is_not_null(),
|
||||
post_like::score.nullable(),
|
||||
coalesce(
|
||||
post_aggregates::comments.nullable() - person_post_aggregates::read_comments.nullable(),
|
||||
|
@ -210,8 +209,13 @@ fn queries<'a>() -> Queries<
|
|||
.eq(local_user_language::language_id)
|
||||
.and(local_user_language::local_user_id.eq(local_user_id_join)),
|
||||
),
|
||||
)
|
||||
.select(selection);
|
||||
);
|
||||
|
||||
if options.saved_only.unwrap_or(false) {
|
||||
query = query.filter(post_saved::id.is_not_null());
|
||||
}
|
||||
|
||||
let mut query = query.select(selection);
|
||||
|
||||
let is_profile_view = options.is_profile_view.unwrap_or(false);
|
||||
let is_creator = options.creator_id == options.local_user.map(|l| l.person.id);
|
||||
|
@ -295,10 +299,6 @@ fn queries<'a>() -> Queries<
|
|||
query = query.filter(person::bot_account.eq(false));
|
||||
};
|
||||
|
||||
if options.saved_only.unwrap_or(false) {
|
||||
query = query.filter(post_saved::post_id.is_not_null());
|
||||
}
|
||||
|
||||
if options.moderator_view.unwrap_or(false) {
|
||||
query = query.filter(community_moderator::person_id.is_not_null());
|
||||
}
|
||||
|
@ -445,12 +445,12 @@ impl JoinView for PostView {
|
|||
post: a.0,
|
||||
creator: a.1,
|
||||
community: a.2,
|
||||
creator_banned_from_community: a.3.is_some(),
|
||||
creator_banned_from_community: a.3,
|
||||
counts,
|
||||
subscribed: CommunityFollower::to_subscribed_type(&a.5),
|
||||
saved: a.6.is_some(),
|
||||
read: a.7.is_some(),
|
||||
creator_blocked: a.8.is_some(),
|
||||
saved: a.6,
|
||||
read: a.7,
|
||||
creator_blocked: a.8,
|
||||
my_vote: a.9,
|
||||
unread_comments: a.10,
|
||||
}
|
||||
|
|
|
@ -28,11 +28,10 @@ use lemmy_db_schema::{
|
|||
post,
|
||||
},
|
||||
source::{
|
||||
comment::{Comment, CommentSaved},
|
||||
comment::Comment,
|
||||
comment_reply::CommentReply,
|
||||
community::{Community, CommunityFollower, CommunityPersonBan},
|
||||
community::{Community, CommunityFollower},
|
||||
person::Person,
|
||||
person_block::PersonBlock,
|
||||
post::Post,
|
||||
},
|
||||
traits::JoinView,
|
||||
|
@ -48,10 +47,10 @@ type CommentReplyViewTuple = (
|
|||
Community,
|
||||
Person,
|
||||
CommentAggregatesNotInComment,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
Option<CommunityFollower>,
|
||||
Option<CommentSaved>,
|
||||
Option<PersonBlock>,
|
||||
bool,
|
||||
bool,
|
||||
Option<i16>,
|
||||
);
|
||||
|
||||
|
@ -113,10 +112,10 @@ fn queries<'a>() -> Queries<
|
|||
community::all_columns,
|
||||
aliases::person1.fields(person::all_columns),
|
||||
CommentAggregatesNotInComment::as_select(),
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
community_follower::all_columns.nullable(),
|
||||
comment_saved::all_columns.nullable(),
|
||||
person_block::all_columns.nullable(),
|
||||
comment_saved::id.nullable().is_not_null(),
|
||||
person_block::id.nullable().is_not_null(),
|
||||
comment_like::score.nullable(),
|
||||
))
|
||||
};
|
||||
|
@ -228,10 +227,10 @@ impl JoinView for CommentReplyView {
|
|||
community: a.4,
|
||||
recipient: a.5,
|
||||
counts,
|
||||
creator_banned_from_community: a.7.is_some(),
|
||||
creator_banned_from_community: a.7,
|
||||
subscribed: CommunityFollower::to_subscribed_type(&a.8),
|
||||
saved: a.9.is_some(),
|
||||
creator_blocked: a.10.is_some(),
|
||||
saved: a.9,
|
||||
creator_blocked: a.10,
|
||||
my_vote: a.11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use lemmy_db_schema::{
|
|||
schema::{community, community_aggregates, community_block, community_follower, local_user},
|
||||
source::{
|
||||
community::{Community, CommunityFollower},
|
||||
community_block::CommunityBlock,
|
||||
local_user::LocalUser,
|
||||
},
|
||||
traits::JoinView,
|
||||
|
@ -29,7 +28,7 @@ type CommunityViewTuple = (
|
|||
Community,
|
||||
CommunityAggregates,
|
||||
Option<CommunityFollower>,
|
||||
Option<CommunityBlock>,
|
||||
bool,
|
||||
);
|
||||
|
||||
fn queries<'a>() -> Queries<
|
||||
|
@ -62,7 +61,7 @@ fn queries<'a>() -> Queries<
|
|||
community::all_columns,
|
||||
community_aggregates::all_columns,
|
||||
community_follower::all_columns.nullable(),
|
||||
community_block::all_columns.nullable(),
|
||||
community_block::id.nullable().is_not_null(),
|
||||
);
|
||||
|
||||
let not_removed_or_deleted = community::removed
|
||||
|
@ -218,7 +217,7 @@ impl JoinView for CommunityView {
|
|||
community: a.0,
|
||||
counts: a.1,
|
||||
subscribed: CommunityFollower::to_subscribed_type(&a.2),
|
||||
blocked: a.3.is_some(),
|
||||
blocked: a.3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,10 +29,9 @@ use lemmy_db_schema::{
|
|||
post,
|
||||
},
|
||||
source::{
|
||||
comment::{Comment, CommentSaved},
|
||||
community::{Community, CommunityFollower, CommunityPersonBan},
|
||||
comment::Comment,
|
||||
community::{Community, CommunityFollower},
|
||||
person::Person,
|
||||
person_block::PersonBlock,
|
||||
person_mention::PersonMention,
|
||||
post::Post,
|
||||
},
|
||||
|
@ -49,10 +48,10 @@ type PersonMentionViewTuple = (
|
|||
Community,
|
||||
Person,
|
||||
CommentAggregatesNotInComment,
|
||||
Option<CommunityPersonBan>,
|
||||
bool,
|
||||
Option<CommunityFollower>,
|
||||
Option<CommentSaved>,
|
||||
Option<PersonBlock>,
|
||||
bool,
|
||||
bool,
|
||||
Option<i16>,
|
||||
);
|
||||
|
||||
|
@ -109,10 +108,10 @@ fn queries<'a>() -> Queries<
|
|||
community::all_columns,
|
||||
aliases::person1.fields(person::all_columns),
|
||||
CommentAggregatesNotInComment::as_select(),
|
||||
community_person_ban::all_columns.nullable(),
|
||||
community_person_ban::id.nullable().is_not_null(),
|
||||
community_follower::all_columns.nullable(),
|
||||
comment_saved::all_columns.nullable(),
|
||||
person_block::all_columns.nullable(),
|
||||
comment_saved::id.nullable().is_not_null(),
|
||||
person_block::id.nullable().is_not_null(),
|
||||
comment_like::score.nullable(),
|
||||
);
|
||||
|
||||
|
@ -245,10 +244,10 @@ impl JoinView for PersonMentionView {
|
|||
community: a.4,
|
||||
recipient: a.5,
|
||||
counts,
|
||||
creator_banned_from_community: a.7.is_some(),
|
||||
creator_banned_from_community: a.7,
|
||||
subscribed: CommunityFollower::to_subscribed_type(&a.8),
|
||||
saved: a.9.is_some(),
|
||||
creator_blocked: a.10.is_some(),
|
||||
saved: a.9,
|
||||
creator_blocked: a.10,
|
||||
my_vote: a.11,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue