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

Properly check whether columns are counter cache in order to display them or not #7347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

plashchynski
Copy link

Check the column is actually a counter cache column. Fixes #7346

@deivid-rodriguez deivid-rodriguez changed the title Check the column is a counter cache. Fixes #7346 Properly check whether columns are counter cache in order to display them or not Jun 20, 2022
@javierjulio
Copy link
Member

I think I would have rather wanted an attribute to an existing model but I’m fine with either approach. Can you please rebase @plashchynski and we’ll merge this? Thank you.

@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (0a1521d) 99.47% compared to head (0bbba63) 99.47%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7347   +/-   ##
=======================================
  Coverage   99.47%   99.47%           
=======================================
  Files         308      308           
  Lines       11306    11334   +28     
=======================================
+ Hits        11247    11275   +28     
  Misses         59       59           
Impacted Files Coverage Δ
features/step_definitions/filesystem_steps.rb 100.00% <100.00%> (ø)
lib/active_admin/resource/attributes.rb 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

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

Since we have parallel tests, I don't want to do the "@changes-db-schema" rollback approach so we can just update an existing model with the cache counter.

Comment on lines +40 to +43
counter_cache_columns = resource_class.reflect_on_all_associations(:has_many)
.select(&:has_cached_counter?)
.map(&:counter_cache_column)
counter_cache_columns.include?(c.name)
Copy link
Member

Choose a reason for hiding this comment

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

Seeing where this method is called as ultimately part of a loop, should we memoize the value?

@javierjulio javierjulio removed the request for review from Fivell May 14, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A show page does not display a field ends with a "_count" substring
4 participants