I have a
Tag model in my app. In one location I want to display a “top 10” list of tags which will show the tags that are most commonly used (by their many-to-many association with the primary models). This will be a query params interface so I can show the top 10 by various criteria and time ranges.
I can see two ways to implement this.
- Add a “count” field to my
Tagmodel which, in most cases will be undefined (or some default value) but when queried at a specific route will be the correct value.
- Create a new
TagCountmodel that is essentially a one-to-many relationship with
Tagwith a single “count” field.
Any thoughts on this or alternate implementations?