Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding report_combined table. #5231

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Adding report_combined table. #5231

wants to merge 5 commits into from

Conversation

dessalines
Copy link
Member

@dessalines dessalines commented Nov 26, 2024

Context: #2444

@dessalines dessalines changed the title Combined tables try 2 WIP: Combined tables try 2 Nov 26, 2024
Copy link
Member Author

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I continue, I'd like @Nutomic , @dullbananas input on this:

  • This PR currently only adds the report_combined table, and I'm thinking the other ones should be separate PRs. Doing a combined table for modlog is going to be really large, and it might be better to do each combined table one PR at a time.

Comment on lines -149 to -156
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
/// Report a comment.
pub struct CreateCommentReport {
pub comment_id: CommentId,
pub reason: String,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved these to a reports specific mod.

Comment on lines 450 to +451
pub struct GetReportCountResponse {
#[cfg_attr(feature = "full", ts(optional))]
pub community_id: Option<CommunityId>,
pub comment_reports: i64,
pub post_reports: i64,
#[cfg_attr(feature = "full", ts(optional))]
pub private_message_reports: Option<i64>,
pub count: i64,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now have a ReportsCombinedInternal::get_report_count(), it seems pointless to get each specific count, and make the front-ends add them, but I can revert this back if necessary.

Comment on lines +656 to +660
-- Combined tables triggers
-- These insert (published, item_id) into X_combined tables
-- Reports
-- Comment
CREATE FUNCTION r.report_combined_comment_report_insert ()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dullbananas I'm not sure if there's a better way to do this, or if we should create some kind of wrapper. It might be a bit verbose, especially when I start adding triggers for every mod table insert.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main changes are in here, and I've added tests for it.

#[cfg_attr(feature = "full", derive(Queryable))]
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
/// A combined report view
pub struct ReportCombinedViewInternal {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to keep this struct as organized as possible, with the specific items first, then the shared last.

@@ -248,6 +251,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
.route("/like", web::post().to(like_post))
.route("/like/list", web::get().to(list_post_likes))
.route("/save", web::put().to(save_post))
// TODO should these be moved into the new report heading?
Copy link
Member Author

@dessalines dessalines Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if report actions should be moved to this new /report heading.

I'm leaning towards no, that it makes sense to keep them at the item-level: IE /post/report .

I'm also wondering whether we should get rid of /item/report/list entirely, and only support the combined one now.

.service(
web::scope("report")
.wrap(rate_limit.message())
.route("/list", web::get().to(list_reports)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, we need a report/list , somewhere.

@dessalines dessalines changed the title WIP: Combined tables try 2 Adding report_combined table. Nov 27, 2024
Comment on lines 1 to 10
-- Creates combined tables for the following:
--
-- Reports: (comment, post, and private_message)
-- Inbox: (Comment replies, post replies, comment mentions, post mentions, private messages)
-- Modlog: (lots of types)
-- Search: (community, post, comment, user, url)
-- TODO not sure about these two:
-- Home: (comment, post)
-- Community: (comment, post)
CREATE TABLE report_combined (
Copy link
Member Author

@dessalines dessalines Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all the places I can think of, to do a combined enum view: Reports, Inbox, Modlog, Profile, and Search.

I'm leaning towards not doing one for Home and Community, since showing new comments next to posts isn't going to be too useful (and the front page sorts are basically useless for comments, these combined tables can only sort by published.)

@dessalines
Copy link
Member Author

dessalines commented Nov 27, 2024

One other thing: @dullbananas can I get your assistance in using cursor pagination (using your library) instead of page / limit? It'd be a good idea to start using cursor pagination for these new combined responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant