Hacker News new | ask | show | jobs
by carlosplusplus 4518 days ago
Thank you for your comment and question, danso.

The particular re-calculation method I presented in this blog post is (hopefully) only going to be run one time, as it serves to recalculate fields based on a database migration. Those fields are counter caches in my Rails models, meaning that their values get +1 automatically when an Answer is generated for a particular Question (approved or not).

Given the nature of the task at hand, I felt it was better practice to keep the model 'clean' and abstract the computation to the rake task itself. The computation will soon be extracted out to a DelayedJob, further isolating the re-calculation method in a modular fashion.

Hope that answers your question!