Fixing import and fmt.

This commit is contained in:
Dessalines 2024-12-08 08:49:26 -05:00
parent 10f5e373cf
commit 02bd2f6764
3 changed files with 11 additions and 14 deletions

View file

@ -180,8 +180,7 @@ pub struct LtreeDef(pub String);
pub struct DbUrl(pub(crate) Box<Url>); pub struct DbUrl(pub(crate) Box<Url>);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)] #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType, TS))] #[cfg_attr(feature = "full", derive(DieselNewType))]
#[cfg_attr(feature = "full", ts(export))]
/// The report combined id /// The report combined id
pub struct ReportCombinedId(i32); pub struct ReportCombinedId(i32);

View file

@ -6,27 +6,21 @@ use chrono::{DateTime, Utc};
use i_love_jesus::CursorKeysModule; use i_love_jesus::CursorKeysModule;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none; use serde_with::skip_serializing_none;
#[cfg(feature = "full")]
use ts_rs::TS;
#[skip_serializing_none] #[skip_serializing_none]
#[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)] #[derive(PartialEq, Eq, Serialize, Deserialize, Debug, Clone)]
#[cfg_attr( #[cfg_attr(
feature = "full", feature = "full",
derive(Identifiable, Queryable, Selectable, TS, CursorKeysModule) derive(Identifiable, Queryable, Selectable, CursorKeysModule)
)] )]
#[cfg_attr(feature = "full", diesel(table_name = report_combined))] #[cfg_attr(feature = "full", diesel(table_name = report_combined))]
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))] #[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
#[cfg_attr(feature = "full", ts(export))]
#[cfg_attr(feature = "full", cursor_keys_module(name = report_combined_keys))] #[cfg_attr(feature = "full", cursor_keys_module(name = report_combined_keys))]
/// A combined reports table. /// A combined reports table.
pub struct ReportCombined { pub struct ReportCombined {
pub id: ReportCombinedId, pub id: ReportCombinedId,
pub published: DateTime<Utc>, pub published: DateTime<Utc>,
#[cfg_attr(feature = "full", ts(optional))]
pub post_report_id: Option<PostReportId>, pub post_report_id: Option<PostReportId>,
#[cfg_attr(feature = "full", ts(optional))]
pub comment_report_id: Option<CommentReportId>, pub comment_report_id: Option<CommentReportId>,
#[cfg_attr(feature = "full", ts(optional))]
pub private_message_report_id: Option<PrivateMessageReportId>, pub private_message_report_id: Option<PrivateMessageReportId>,
} }

View file

@ -13,6 +13,7 @@ use diesel::{
ExpressionMethods, ExpressionMethods,
JoinOnDsl, JoinOnDsl,
NullableExpressionMethods, NullableExpressionMethods,
PgExpressionMethods,
QueryDsl, QueryDsl,
SelectableHelper, SelectableHelper,
}; };
@ -79,9 +80,12 @@ impl ReportCombinedViewInternal {
Some(my_person_id), Some(my_person_id),
post::community_id, post::community_id,
)) ))
.filter(post_report::resolved .filter(
.or(comment_report::resolved) post_report::resolved
.or(private_message_report::resolved).is_distinct_from(true)) .or(comment_report::resolved)
.or(private_message_report::resolved)
.is_distinct_from(true),
)
.into_boxed(); .into_boxed();
if let Some(community_id) = community_id { if let Some(community_id) = community_id {
@ -306,9 +310,9 @@ impl ReportCombinedQuery {
query = query query = query
.filter( .filter(
post_report::resolved post_report::resolved
.or(comment_report::resolved) .or(comment_report::resolved)
.or(private_message_report::resolved).is_distinct_from(true), .or(private_message_report::resolved)
.is_distinct_from(true),
) )
// TODO: when a `then_asc` method is added, use it here, make the id sort direction match, // TODO: when a `then_asc` method is added, use it here, make the id sort direction match,
// and remove the separate index; unless additional columns are added to this sort // and remove the separate index; unless additional columns are added to this sort