Remove pointless post_tags types.

This commit is contained in:
Dessalines 2024-12-19 18:07:59 -05:00
parent 9a0e050ee6
commit 776c5007a1
3 changed files with 25 additions and 44 deletions

View file

@ -10,11 +10,8 @@ use crate::{
InternalToCombinedView,
};
use diesel::{
pg::Pg,
result::Error,
sql_types,
BoolExpressionMethods,
BoxableExpression,
ExpressionMethods,
JoinOnDsl,
NullableExpressionMethods,
@ -103,18 +100,14 @@ impl PersonContentCombinedQuery {
let conn = &mut get_conn(pool).await?;
let post_tags: Box<
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false))
.single_value(),
);
let post_tags = post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false))
.single_value();
// Notes: since the post_id and comment_id are optional columns,
// many joins must use an OR condition.

View file

@ -8,11 +8,8 @@ use crate::{
InternalToCombinedView,
};
use diesel::{
pg::Pg,
result::Error,
sql_types,
BoolExpressionMethods,
BoxableExpression,
ExpressionMethods,
JoinOnDsl,
NullableExpressionMethods,
@ -97,18 +94,14 @@ impl PersonSavedCombinedQuery {
let conn = &mut get_conn(pool).await?;
let post_tags: Box<
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false))
.single_value(),
);
let post_tags = post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post::id))
.filter(tag::deleted.eq(false))
.single_value();
// Notes: since the post_id and comment_id are optional columns,
// many joins must use an OR condition.

View file

@ -5,9 +5,7 @@ use diesel::{
pg::Pg,
query_builder::AsQuery,
result::Error,
sql_types,
BoolExpressionMethods,
BoxableExpression,
ExpressionMethods,
JoinOnDsl,
NullableExpressionMethods,
@ -97,18 +95,15 @@ fn queries<'a>() -> Queries<
// If we want to filter by post tag we will have to add
// separate logic below since this subquery can't affect filtering, but it is simple (`WHERE
// exists (select 1 from post_community_post_tags where community_post_tag_id in (1,2,3,4)`).
let post_tags: Box<
dyn BoxableExpression<_, Pg, SqlType = sql_types::Nullable<sql_types::Json>>,
> = Box::new(
post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post_aggregates::post_id))
.filter(tag::deleted.eq(false))
.single_value(),
);
let post_tags = post_tag::table
.inner_join(tag::table)
.select(diesel::dsl::sql::<diesel::sql_types::Json>(
"json_agg(tag.*)",
))
.filter(post_tag::post_id.eq(post_aggregates::post_id))
.filter(tag::deleted.eq(false))
.single_value();
query
.inner_join(person::table)
.inner_join(community::table)