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