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

Tag counter in parent model #8

Open
christianhager opened this issue Aug 20, 2011 · 4 comments
Open

Tag counter in parent model #8

christianhager opened this issue Aug 20, 2011 · 4 comments

Comments

@christianhager
Copy link

Hi, thanks for this great tool! A true time-saver. I was also looking for a way to scope the tag-counter into some parent model.

In addition to
Account.tags_with_weight

I want to do
current_account.tags_with_weight

I came up with this

class Account
      include Mongoid::TaggableWithContext::RealTimeCounter
      count_tags_for :tags
end

Then in the taggable model you can do this:

class MyModel
     include Mongoid::TaggableWithContext
     include Mongoid::TaggableWithContext::AggregationStrategy::RealTime

     belongs_to :account
     taggable :tags, :counter_in => :account
end

What do you think about the idea? I would gladly push some code, but had some trouble getting the specs to run as it needs mongo 1.8. I will try to get that sorted out, but would love to hear your thoughts on the idea first.

@aq1018
Copy link
Owner

aq1018 commented Dec 20, 2011

I think this is a similar issue as #10 if I understand correctly. Can you elaborate a bit more on what you are trying to accomplish? Specifically, what kind of data are you trying to aggregate? per user, per model, and per context tagging?

@aq1018
Copy link
Owner

aq1018 commented Dec 20, 2011

some sort of tagger functionality?

@aq1018
Copy link
Owner

aq1018 commented Jan 28, 2012

If I understand correctly think the account model is a tagger, and you want to aggregate based on tagger information as well.

I'm thinking about how best to represent the taggable, tagger, and tags in mongo db. Will probably implement something pretty soon.

@christianhager
Copy link
Author

Sorry for my late reply! I want to be able to store the weight of tags in another model. I created a solution based on your gem to solve this, but I think the aggregation is way to costly in my implementation. I also added support to add more meta then just the counter. Perhaps you want to take a look at it: https://github.com/christianhager/mongoid_tag

Its not a good idea to create a gem that is almost a copy of yours, but I wanted to learn how to make a gem as well.

johnnyshields referenced this issue in johnnyshields/mongoid_taggable_with_context May 20, 2013
Code cleanup + Mongoid options pass-thru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants