Count for specific action #49

Closed
Simbul opened this Issue Jul 30, 2012 · 2 comments

Projects

None yet

4 participants

@Simbul
Simbul commented Jul 30, 2012

Is there any way of getting the impressionist_count method to return only the count for a specific action?

If it's there, I could not find it. The information is in the database already, though, which would make it a nice and easy addition in my opinion: it's only an issue of deciding for a method signature.

A possibility could be

impressionist_count(:where => { :action_name => 'show' })

This should fit in nicely with the syntax for ActiveRecord's where.

@jgwmaxwell
Contributor

There comes a point where piling more and more functionality through a single method call becomes a poor design choice - really, if you wanted this kind of feature, there should be another function such as:

impressionist_count_by_action('show')

Personally, I'd suggest just querying the impression model directly - as you say, it has all the information you need and still only takes a single line. If you really wanted to make a simple way of doing it, you could even write a scope.

@dmons
dmons commented Aug 10, 2012

It's a pretty simple feature, I wrote it for AR in my app in 5min. Why you couldn't include this in gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment