From f0b00ccf946695c992f20a02c64a7374084d770d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 7 Feb 2025 07:51:32 -0500 Subject: [PATCH] Fixing a few view's saved columns to use the optional datetime. (#5402) - Also adds some comments for them, since its a nullable string in the generated types. --- .../src/combined/inbox_combined_view.rs | 4 +-- .../src/combined/report_combined_view.rs | 4 +-- crates/db_views/src/comment/comment_view.rs | 2 +- .../src/reports/comment_report_view.rs | 2 +- .../db_views/src/reports/post_report_view.rs | 2 +- crates/db_views/src/structs.rs | 34 +++++++++++++------ 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/crates/db_views/src/combined/inbox_combined_view.rs b/crates/db_views/src/combined/inbox_combined_view.rs index 7e7bc1f20..352aff687 100644 --- a/crates/db_views/src/combined/inbox_combined_view.rs +++ b/crates/db_views/src/combined/inbox_combined_view.rs @@ -293,7 +293,7 @@ impl InboxCombinedQuery { post_aggregates::comments, ) .nullable(), - post_actions::saved.nullable().is_not_null(), + post_actions::saved.nullable(), post_actions::read.nullable().is_not_null(), post_actions::hidden.nullable().is_not_null(), post_actions::like_score.nullable(), @@ -305,7 +305,7 @@ impl InboxCombinedQuery { community::all_columns.nullable(), comment::all_columns.nullable(), comment_aggregates::all_columns.nullable(), - comment_actions::saved.nullable().is_not_null(), + comment_actions::saved.nullable(), comment_actions::like_score.nullable(), CommunityFollower::select_subscribed_type(), person::all_columns, diff --git a/crates/db_views/src/combined/report_combined_view.rs b/crates/db_views/src/combined/report_combined_view.rs index 115c8413a..025d24f33 100644 --- a/crates/db_views/src/combined/report_combined_view.rs +++ b/crates/db_views/src/combined/report_combined_view.rs @@ -281,7 +281,7 @@ impl ReportCombinedQuery { post_aggregates::comments, ) .nullable(), - post_actions::saved.nullable().is_not_null(), + post_actions::saved.nullable(), post_actions::read.nullable().is_not_null(), post_actions::hidden.nullable().is_not_null(), post_actions::like_score.nullable(), @@ -289,7 +289,7 @@ impl ReportCombinedQuery { comment_report::all_columns.nullable(), comment::all_columns.nullable(), comment_aggregates::all_columns.nullable(), - comment_actions::saved.nullable().is_not_null(), + comment_actions::saved.nullable(), comment_actions::like_score.nullable(), // Private-message-specific private_message_report::all_columns.nullable(), diff --git a/crates/db_views/src/comment/comment_view.rs b/crates/db_views/src/comment/comment_view.rs index 8b2794217..aef8a4891 100644 --- a/crates/db_views/src/comment/comment_view.rs +++ b/crates/db_views/src/comment/comment_view.rs @@ -135,7 +135,7 @@ impl CommentView { creator_is_moderator: self.creator_is_moderator, creator_is_admin: self.creator_is_admin, subscribed: self.subscribed, - saved: self.saved.is_some(), + saved: self.saved, creator_blocked: self.creator_blocked, my_vote: self.my_vote, } diff --git a/crates/db_views/src/reports/comment_report_view.rs b/crates/db_views/src/reports/comment_report_view.rs index a2fa22a26..2ca059147 100644 --- a/crates/db_views/src/reports/comment_report_view.rs +++ b/crates/db_views/src/reports/comment_report_view.rs @@ -136,7 +136,7 @@ impl CommentReportView { local_user::admin.nullable().is_not_null(), person_actions::blocked.nullable().is_not_null(), CommunityFollower::select_subscribed_type(), - comment_actions::saved.nullable().is_not_null(), + comment_actions::saved.nullable(), comment_actions::like_score.nullable(), aliases::person2.fields(person::all_columns).nullable(), )) diff --git a/crates/db_views/src/reports/post_report_view.rs b/crates/db_views/src/reports/post_report_view.rs index 100703f06..5f246be9d 100644 --- a/crates/db_views/src/reports/post_report_view.rs +++ b/crates/db_views/src/reports/post_report_view.rs @@ -120,7 +120,7 @@ impl PostReportView { .is_not_null(), local_user::admin.nullable().is_not_null(), CommunityFollower::select_subscribed_type(), - post_actions::saved.nullable().is_not_null(), + post_actions::saved.nullable(), post_actions::read.nullable().is_not_null(), post_actions::hidden.nullable().is_not_null(), person_actions::blocked.nullable().is_not_null(), diff --git a/crates/db_views/src/structs.rs b/crates/db_views/src/structs.rs index fe420a645..23996a8d1 100644 --- a/crates/db_views/src/structs.rs +++ b/crates/db_views/src/structs.rs @@ -103,7 +103,9 @@ pub struct CommentReportView { pub creator_is_admin: bool, pub creator_blocked: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the comment was saved. + pub saved: Option>, #[cfg_attr(feature = "full", ts(optional))] pub my_vote: Option, #[cfg_attr(feature = "full", ts(optional))] @@ -182,6 +184,7 @@ pub struct CommentView { comment_actions::saved.nullable() ) )] + /// The time when the comment was saved. pub saved: Option>, #[cfg_attr(feature = "full", diesel( @@ -215,7 +218,9 @@ pub struct CommentSlimView { pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the comment was saved. + pub saved: Option>, pub creator_blocked: bool, #[cfg_attr(feature = "full", ts(optional))] pub my_vote: Option, @@ -269,7 +274,9 @@ pub struct PostReportView { pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the post was saved. + pub saved: Option>, pub read: bool, pub hidden: bool, pub creator_blocked: bool, @@ -327,6 +334,7 @@ pub struct PostView { pub counts: PostAggregates, pub subscribed: SubscribedType, #[cfg_attr(feature = "full", ts(optional))] + /// The time when the post was saved. pub saved: Option>, pub read: bool, pub hidden: bool, @@ -436,7 +444,7 @@ pub struct ReportCombinedViewInternal { pub post: Option, pub post_counts: Option, pub post_unread_comments: Option, - pub post_saved: bool, + pub post_saved: Option>, pub post_read: bool, pub post_hidden: bool, pub my_post_vote: Option, @@ -444,7 +452,7 @@ pub struct ReportCombinedViewInternal { pub comment_report: Option, pub comment: Option, pub comment_counts: Option, - pub comment_saved: bool, + pub comment_saved: Option>, pub my_comment_vote: Option, // Private-message-specific pub private_message_report: Option, @@ -623,7 +631,9 @@ pub struct PersonCommentMentionView { pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the comment was saved. + pub saved: Option>, pub creator_blocked: bool, #[cfg_attr(feature = "full", ts(optional))] pub my_vote: Option, @@ -649,7 +659,9 @@ pub struct PersonPostMentionView { pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the post was saved. + pub saved: Option>, pub read: bool, pub hidden: bool, pub creator_blocked: bool, @@ -678,7 +690,9 @@ pub struct CommentReplyView { pub creator_is_moderator: bool, pub creator_is_admin: bool, pub subscribed: SubscribedType, - pub saved: bool, + #[cfg_attr(feature = "full", ts(optional))] + /// The time when the comment was saved. + pub saved: Option>, pub creator_blocked: bool, #[cfg_attr(feature = "full", ts(optional))] pub my_vote: Option, @@ -752,7 +766,7 @@ pub struct InboxCombinedViewInternal { pub person_post_mention: Option, pub post_counts: Option, pub post_unread_comments: Option, - pub post_saved: bool, + pub post_saved: Option>, pub post_read: bool, pub post_hidden: bool, pub my_post_vote: Option, @@ -765,7 +779,7 @@ pub struct InboxCombinedViewInternal { pub community: Option, pub comment: Option, pub comment_counts: Option, - pub comment_saved: bool, + pub comment_saved: Option>, pub my_comment_vote: Option, pub subscribed: SubscribedType, pub item_creator: Person,