Determine number of upvotes based on who created a thing

I’m trying to create a karma system that creates a count of all the upvotes on modules that have been created by the current user.

On my User model, I’m tracking the list of modules that have been created.

I also have a Votes model, which tracks which module was up or downvoted.

I have a text field that does a search for votes, but can’t figure out the right syntax to only count the number of upvotes on all modules that were created by the current user. I haven’t been able to find any examples of this, but am probably not using the right search terms.

I won’t say I figured out a solution to this problem, but figured out a workaround for anyone else who stumbles into this problem. I can’t figure out how to get the “intersects with” logic to work (which I think is the right path), having tried what seems to be every permutation available.

Instead, I’m just going to add the module’s creator to each vote that gets created so I can do a search for any vote that is an upvote and also matches the current user. Maybe not as elegant but it works.

This topic was automatically closed after 70 days. New replies are no longer allowed.