-
-
Notifications
You must be signed in to change notification settings - Fork 883
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.
Co-authored-by: dullbananas <[email protected]>
Co-authored-by: dullbananas <[email protected]>
Co-authored-by: dullbananas <[email protected]>
Co-authored-by: dullbananas <[email protected]>
Co-authored-by: dullbananas <[email protected]>
-- 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.
Maybe rename these columns to published
while youre at it, because its inconsistent with other tables.
ModlogCombinedView::ModTransferCommunity(v) => { | ||
("ModTransferCommunity", v.mod_transfer_community.id.0) | ||
} | ||
}; |
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.
You can use strum to avoid typing out all the enum names. Then you only need to return the id from match.
"ModRemoveComment" => query.filter(modlog_combined::mod_remove_comment_id.eq(id)), | ||
"ModRemoveCommunity" => query.filter(modlog_combined::mod_remove_community_id.eq(id)), | ||
"ModRemovePost" => query.filter(modlog_combined::mod_remove_post_id.eq(id)), | ||
"ModTransferCommunity" => query.filter(modlog_combined::mod_transfer_community_id.eq(id)), |
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.
This could also potentially work with strum to convert string into enum variant with default value 0 as id. That way you dont need to type out strings for the match which could have typos.
} | ||
ModlogActionType::AdminAllowInstance => { | ||
query.filter(modlog_combined::admin_allow_instance_id.is_not_null()) | ||
} |
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.
You can make this easier to read by putting use modlog_combined::*
just before the match. Maybe the compiler will give a warning then youd have to move the match into a separate function.
impl InternalToCombinedView for ModlogCombinedViewInternal { | ||
type CombinedView = ModlogCombinedView; | ||
|
||
fn map_to_enum(&self) -> Option<Self::CombinedView> { |
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.
fn map_to_enum(&self) -> Option<Self::CombinedView> { | |
fn map_to_enum(self) -> Option<Self::CombinedView> { |
Then theres no need for any clone below.
@@ -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.
Can remove this comment.
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
.