Comments (6)
Interesting; if I understand this correctly, the counter cache incrementing / decrementing itself works correctly for this, just the counter_culture_fix_counts call doesn't? That's at least the behavior I would expect -- the increment / decrement queries are atomical and incremental, thus should build on top of each other. But the fix_counts is not designed to take into account the possibility that there are multiple different counter_culture statements that write to the same column. I wouldn't be opposed to adding this if you can come up with a pull request, though the logic in fix_counts is becoming increasingly complex, so I do not know how feasible that would be.
In all honesty, I would advise you to just avoid using fix_counts here. Do use counter_culture for the incrementing / decrementing -- it should work fine for that -- but just roll your own simple fix-up script using find_each. It's not as fast as using counter_culture's database-level fixing but unless your accounts table is huge, that really shouldn't be a problem.
Closing, as I won't have the time to address this myself. But again, very happy to look at a PR.
from counter_culture.
Thanks, Magnus!
from counter_culture.
Hi Magnus
I was digging through the docs for counter_culture, because I thought I saw a way to move counters to a different table. I donβt see that info in the docs anymore and wanted to check with you to see if counter_culture has a way of pointing the counter cache to a different table (not the one named after the model the counter_culture method call is in).
Thanks
Adam
Adam Stockland
On Jun 9, 2014, at 7:10 PM, Magnus von Koeller [email protected] wrote:
Closed #55.
β
Reply to this email directly or view it on GitHub.
from counter_culture.
The counter cache column is not on the model where you put the counter_culture call, it's on the association that you specify there. You can see that in the simple example here: The counter_cache call is in Product
but the cache column is in the categories
table. You can take that further with multi-level counter-caches. Note, however, that the behavior there changes, also, as the counter-cache gets aggregated over the entire hierarchy.
from counter_culture.
Sorry, I didn't do a good job at wording my email. I'm looking to move the
counters into a third, counter dedicated, model.
Adam
On Tuesday, July 22, 2014, Magnus von Koeller [email protected]
wrote:
The counter cache column is not on the model where you put the
counter_culture call, it's on the association that you specify there. You
can see that in the simple example here
https://github.com/magnusvk/counter_culture#simple-counter-cache: The
counter_cache call is in Product but the cache column is in the categories
table. You can take that further with multi-level counter-caches
https://github.com/magnusvk/counter_culture#multi-level-counter-cache.
Note, however, that the behavior there changes, also, as the counter-cache
gets aggregated over the entire hierarchy.β
Reply to this email directly or view it on GitHub
#55 (comment)
.
from counter_culture.
So I'm not quite clear what the use-case here would be, so I'm not entirely sure how to answer your question. But if there was another model that had a 1:1 mapping with your dependent model, you should be able to use multi-level counter-caches to move your counter cache there. Is that what you mean?
from counter_culture.
Related Issues (20)
- How to decrement count when an attribute value changes? HOT 1
- Request: Callback support on parent models HOT 1
- Multiple counters, single query HOT 4
- Incorrect count when using ID in the dynamic column name proc HOT 2
- Model.counter_culture_fix_counts does nothing after the initial run HOT 1
- How to update with habtm when products have conditions? HOT 8
- Multi-level association 3-deep works in the console, but fails every test and in production HOT 3
- counter_culture_fix_counts with where clause HOT 2
- Two counters of the same model, one scoped the other not HOT 1
- jsonb support HOT 1
- what is the drawback of using active records callback instead this gem? HOT 1
- PG::UndefinedColumn: ERROR: column "nan" does not exist HOT 3
- Add "where" option to the `counter_culture` method HOT 1
- STI and Polymorphic issue with fix counts method on self-referential models HOT 4
- Updating counts is associations active HOT 1
- Dynamic column name that uses model primary key causes all updates to increment the counter HOT 2
- Column_names not accepting proc with hash HOT 1
- Call to `previous_model` is triggering `transaction_changed_attributes` callbacks causing changes to be overwritten HOT 5
- Undefined Method `current_time_from_proper_timezone' Error HOT 1
- Adding :if / :unless for conditional counter caches HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from counter_culture.