diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 073e2ec08ae..f20cc8c6376 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -1,4 +1,6 @@ class UserAction < ActiveRecord::Base + include DateGroupable + belongs_to :user belongs_to :target_post, class_name: "Post" belongs_to :target_topic, class_name: "Topic" @@ -119,6 +121,13 @@ SQL end + def self.count_daily_engaged_users(start_date, end_date) + select(:user_id).distinct + .where(action_type: [LIKE, NEW_TOPIC, REPLY, NEW_PRIVATE_MESSAGE]) + .smart_group_by_date(:created_at, start_date, end_date) + .count + end + def self.stream_item(action_id, guardian) stream(action_id: action_id, guardian: guardian).first end