Class: Stats::UserTagsQuery
- Inherits:
-
Object
- Object
- Stats::UserTagsQuery
- Defined in:
- app/models/stats/user_tags_query.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user) ⇒ UserTagsQuery
constructor
A new instance of UserTagsQuery.
- #result ⇒ Object
- #sql ⇒ Object private
Constructor Details
#initialize(user) ⇒ UserTagsQuery
Returns a new instance of UserTagsQuery.
5 6 7 |
# File 'app/models/stats/user_tags_query.rb', line 5 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/models/stats/user_tags_query.rb', line 3 def user @user end |
Instance Method Details
#result ⇒ Object
9 10 11 |
# File 'app/models/stats/user_tags_query.rb', line 9 def result user.todos.find_by_sql([sql, user.id]) end |
#sql ⇒ Object (private)
15 16 17 18 19 20 21 22 23 |
# File 'app/models/stats/user_tags_query.rb', line 15 def sql <<-SQL SELECT tags.id as id FROM tags, taggings, todos WHERE tags.id = taggings.tag_id AND taggings.taggable_id = todos.id AND todos.user_id = ? SQL end |