mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-23 18:35:56 +00:00
3f06317878
* Renaming person_mention to person_comment_mention. * Finishing up post body mentions. * Combined tables try 2 * Finishing up combined report table. * Fix ts optionals. * Adding tests, triggers, and history updates for report_combined. * Adding profile. * Add cursor pagination to report_combined view (#5244) * add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit89359dde4b
. * use paginated query builder * Fixing migration and paged API. * Using dullbananas trigger procedure * Removing pointless list routes, reorganizing tests. * Fixing column XOR check. * Forgot to remove list report actions. * Cleanup. * Use internal tagging. * Fixing api tests. * Adding a few indexes. * Fixing migration name. * Fixing unique constraints. * Addressing PR comments. * Start working on profile combined * Adding views and replaceable schema. * A few changes to profile view. - Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view. * Finishing up combined person_saved and person_content. * Fixing api tests. * Moving to api-v4 routes. * Fixing imports. * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views/src/report_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update migrations/2024-12-02-181601_add_report_combined_table/up.sql Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Fixing import and fmt. * Fixing null types in postgres. * Comment out err. * Fixing TS issues. * Adding types, fixing allow and blocklist crud. * Starting to work on combined views. * Using dullbananas trigger procedure * Adding the full combined view queries. * Adding tests. * taplo fmt. * Upgrading package.json deps. * Updating pnpm * Most of the bulk work done, need to add tests yet. * Finishing up inbox. * Using assert_length * Fixing sql_format. * Running fmt. * Fixing cargo shear. * Fixing clippy. * Addressing PR comments. * Removing serialization * Removing serialization * Fixing duped trigger. * Remove saved_only test. * Remove pointless post_tags types. * Remove pointless index. * Changing published to saved for person_saved_combined. * Removing comment. * Renaming modlog when_ columns to published. - Fixes #5312 * Adding strum and simplifying imports. * Avoiding clone in map_to_enum * Changing modded_person to other_person. * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/db_views_moderator/src/modlog_combined_view.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Addressing PR comments. * Fixing split. * Revert "Adding strum and simplifying imports." This reverts commit15f1671107
. * Running fmt. * Using assert + matches instead of filter_map. * Adding listPersonContent check. * Updating lemmy-js-client * Fixing mark all as read route, changing mark read to SuccessResponse. * Adding post body mention api test, fixing api tests. * Fixing route locations, and api tests. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
69 lines
2.1 KiB
SQL
69 lines
2.1 KiB
SQL
-- Creates combined tables for
|
|
-- Inbox: (replies, comment mentions, post mentions, and private_messages)
|
|
-- Also add post mentions, since these didn't exist before.
|
|
-- Rename the person_mention table to person_comment_mention
|
|
ALTER TABLE person_mention RENAME TO person_comment_mention;
|
|
|
|
-- Create the new post_mention table
|
|
CREATE TABLE person_post_mention (
|
|
id serial PRIMARY KEY,
|
|
recipient_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
|
read boolean DEFAULT FALSE NOT NULL,
|
|
published timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (recipient_id, post_id)
|
|
);
|
|
|
|
CREATE TABLE inbox_combined (
|
|
id serial PRIMARY KEY,
|
|
published timestamptz NOT NULL,
|
|
comment_reply_id int UNIQUE REFERENCES comment_reply ON UPDATE CASCADE ON DELETE CASCADE,
|
|
person_comment_mention_id int UNIQUE REFERENCES person_comment_mention ON UPDATE CASCADE ON DELETE CASCADE,
|
|
person_post_mention_id int UNIQUE REFERENCES person_post_mention ON UPDATE CASCADE ON DELETE CASCADE,
|
|
private_message_id int UNIQUE REFERENCES private_message ON UPDATE CASCADE ON DELETE CASCADE,
|
|
-- Make sure only one of the columns is not null
|
|
CHECK (num_nonnulls (comment_reply_id, person_comment_mention_id, person_post_mention_id, private_message_id) = 1)
|
|
);
|
|
|
|
CREATE INDEX idx_inbox_combined_published ON inbox_combined (published DESC, id DESC);
|
|
|
|
CREATE INDEX idx_inbox_combined_published_asc ON inbox_combined (reverse_timestamp_sort (published) DESC, id DESC);
|
|
|
|
-- Updating the history
|
|
INSERT INTO inbox_combined (published, comment_reply_id, person_comment_mention_id, person_post_mention_id, private_message_id)
|
|
SELECT
|
|
published,
|
|
id,
|
|
NULL::int,
|
|
NULL::int,
|
|
NULL::int
|
|
FROM
|
|
comment_reply
|
|
UNION ALL
|
|
SELECT
|
|
published,
|
|
NULL::int,
|
|
id,
|
|
NULL::int,
|
|
NULL::int
|
|
FROM
|
|
person_comment_mention
|
|
UNION ALL
|
|
SELECT
|
|
published,
|
|
NULL::int,
|
|
NULL::int,
|
|
id,
|
|
NULL::int
|
|
FROM
|
|
person_post_mention
|
|
UNION ALL
|
|
SELECT
|
|
published,
|
|
NULL::int,
|
|
NULL::int,
|
|
NULL::int,
|
|
id
|
|
FROM
|
|
private_message;
|
|
|