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

FIX: N1 in post action extension #292

Merged
merged 2 commits into from
May 21, 2024

Conversation

martin-brennan
Copy link
Contributor

@martin-brennan martin-brennan commented May 20, 2024

Followup 0b4b186

The previous commit caused an N1 because I was calling
post_action.reaction_user in a loop, which was making
a query for every Like PostAction attached to a Post.

plugin.rb Outdated
@@ -104,6 +104,20 @@ class Engine < ::Rails::Engine

reaction_users_counting_as_like.flatten!

# Used to remove historical like data in the filter below.
previous_main_reaction_like_ids =
Copy link
Contributor Author

@martin-brennan martin-brennan May 20, 2024

Choose a reason for hiding this comment

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

We can potentially add a spec using track_sql_queries for this, but since this is one of many add_to_serializer modifications to the PostSerializer, it's not really possible to do a clean before/after comparison without some more extensive refactoring, which I do not think is worth it at this time. Confirmed that the N1 is now gone locally.

Followup 0b4b186

The previous commit caused an N1 because I was calling
post_action.reaction_user in a loop, which was making
a query for every Like PostAction attached to a Post.
@martin-brennan martin-brennan force-pushed the issue/fix-n1-post-action-extension branch from 1e0844f to f6a847a Compare May 20, 2024 05:39
plugin.rb Outdated Show resolved Hide resolved
plugin.rb Outdated Show resolved Hide resolved
@martin-brennan martin-brennan force-pushed the issue/fix-n1-post-action-extension branch 2 times, most recently from ece718c to 46284bf Compare May 21, 2024 02:29
plugin.rb Outdated Show resolved Hide resolved
@martin-brennan martin-brennan force-pushed the issue/fix-n1-post-action-extension branch from 46284bf to 88b849c Compare May 21, 2024 03:16
@martin-brennan martin-brennan merged commit e5e40b9 into main May 21, 2024
5 checks passed
@martin-brennan martin-brennan deleted the issue/fix-n1-post-action-extension branch May 21, 2024 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants