class Post < ActiveRecord::Base
include PublicActivity::Model
tracked owner: :user
I'm using the PublicActivity gem to track the "update" action on the Post model. The problem is that if a user clicks on "Update post" 3 times in a minute I get 3 activities for the same "updated post". Is there a way to save an activity only in a range of X-minutes? To prevent flooding.
EDIT:
Maybe a scheduled job to clean up duplicated data?
activity = PublicActivity::Activity.where(trackable_id: post.id, owner_id: current_user.id).last
if activity?
period = Time.zone.now - activity.created_at
if period > 60 # or any time sec
@post.create_activity # your activity creation
end
else
@post.create_activity # your activity creation
end