-
-
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
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.
This is ready for review now. |
crates/api_common/src/utils.rs
Outdated
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.
let posts_mapped = &post_modlog.iter().filter_map(|p| { | |
if let ModlogCombinedView::ModRemovePost(v) = p { | |
Some(v) | |
} else { | |
None | |
} | |
}); | |
let posts_mapped = &post_modlog.iter().filter_map(|p| { | |
if let ModlogCombinedView::ModRemovePost(v) = p { | |
Some((v.mod_remove_post.removed, v.post.removed)) | |
} else { | |
None | |
} | |
}).collect::<Vec<bool>>(); |
then replace the things below with a single assert_eq
same can be done for the other uses of filter_map
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.
K done now. I didn't like doing it because its less clear now what they're doing, and these are just tests, where clarity should be preferred over code simplification.
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.
I think I came up with a style that's more simple and clear than the other two:
assert!(matches!(
&post_modlog[..],
[
ModlogCombinedView::ModRemovePost(ModRemovePostView {
mod_remove_post: ModRemovePost { removed: true, .. },
post: Post { removed: true, .. },
..
}),
ModlogCombinedView::ModRemovePost(ModRemovePostView {
mod_remove_post: ModRemovePost { removed: true, .. },
post: Post { removed: true, .. },
..
}),
],
));
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.
That does look much cleaner, I'll try it out.
"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.
EnumDiscriminants might help
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
…nto combined_modlog
Probably not worth it to do any of the enum work. All the other combined cases just use a single char for the paging, this one's unique in that there are 17 types it needs to combine. EDIT: I'm reverting adding strum at all because of this. |
This reverts commit 15f1671.
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
.