-
-
Notifications
You must be signed in to change notification settings - Fork 886
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 Combined modlog #5253
base: main
Are you sure you want to change the base?
Adding Combined modlog #5253
Conversation
* add pagination cursor * store timestamp instead of id in cursor (partial) * Revert "store timestamp instead of id in cursor (partial)" This reverts commit 89359dd. * use paginated query builder
…into combined_tables_2
…into combined_tables_2
- Separating the profile fetch from its combined content fetch. - Starting to separate saved_only into its own combined view.
crates/api/src/site/mod_log.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API changes here let us remove all these view types.
pub type_: Option<ModlogActionType>, | ||
#[cfg_attr(feature = "full", ts(optional))] | ||
pub other_person_id: Option<PersonId>, | ||
pub modded_person_id: Option<PersonId>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the name of this everywhere I could, to be more consistent.
crates/api_common/src/site.rs
Outdated
@@ -168,23 +150,7 @@ pub struct GetModlog { | |||
/// The modlog fetch response. | |||
// TODO this should be redone as a list of tagged enums |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
let posts_mapped = &post_modlog.iter().filter_map(|p| { | ||
if let ModlogCombinedView::ModRemovePost(v) = p { | ||
Some(v) | ||
} else { | ||
None | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were necessary for tests. If anyone's wondering how to force the combined types into its specific one, you can use .filter_map
like this above.
@@ -761,3 +761,78 @@ CALL r.create_person_saved_combined_trigger ('post'); | |||
|
|||
CALL r.create_person_saved_combined_trigger ('comment'); | |||
|
|||
-- modlog: (17 tables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaceable schema changes below.
@@ -19,25 +39,23 @@ use diesel_async::RunQueryDsl; | |||
impl Crud for AdminPurgePerson { | |||
type InsertForm = AdminPurgePersonForm; | |||
type UpdateForm = AdminPurgePersonForm; | |||
type IdType = i32; | |||
type IdType = AdminPurgePersonId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in all these db_schema
files are just adding the type, and some cleaner imports. So no need to read through them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these views are unecessary, as we should always used the combined view for them. Eliminates a lot of code 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main work of the PR is in this file. What's most important is that I've added a lot of tests to make sure all these are working.
-- Not doing a union all here, because there's way too many null columns | ||
INSERT INTO modlog_combined (published, admin_allow_instance_id) | ||
SELECT | ||
when_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmk if you think this is worth it. Its a lot of work but I'll do it if you think I should.
This is ready for review now. |
Context: #2444
Must come after #5251
Notes:
type_
filter.mod_remove_post
doesn't have themodded_person_id
directly on it, it needs to get it from thepost.creator_id
column. I've tried to keep the joins as organized and well-commented as possible.v3
routes. I am not going to do backwards compatibility for these types. That will have to be handled by API libraries switching onv.0.19
vsv.0.20
.