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

Backport 'Add votes count to comment caches' to v0.27 #12782

Conversation

andreslucena
Copy link
Member

🎩 What? Why?

Backport #12551 to v0.27

♥️ Thank you!

* Add votes count to comment caches

* Use size instead of count method

Co-authored-by: Alexandru Emil Lupu <contact@alecslupu.ro>

* Implement counter_cache for comment's votes

We need to handle the counter_cache manually as we have an scoped
association (i.e. with the lambda that does the where in the relation)

> has_many :up_votes, -> { where(weight: 1) }

So, for this reason we need to do handle the update with a callback in
CommentVote and can't use the reset_counters in the migration.

* Explicitly use the counter_cache attributes in comment cell

---------

Co-authored-by: Alexandru Emil Lupu <contact@alecslupu.ro>
@andreslucena andreslucena added backport Pull Requests that are a backport for a fixed bug module: comments type: fix PRs that implement a fix for a bug labels Apr 26, 2024
@alecslupu alecslupu added this to the 0.27.6 milestone Apr 29, 2024
Copy link
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

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

👍

@alecslupu alecslupu merged commit 2fdb64d into release/0.27-stable Apr 29, 2024
22 checks passed
@alecslupu alecslupu deleted the backport/0.27/add-votes-count-to-comment-cac-12551 branch April 29, 2024 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Pull Requests that are a backport for a fixed bug module: comments type: fix PRs that implement a fix for a bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants