-
Notifications
You must be signed in to change notification settings - Fork 30
Duplicate activity entries #1
Comments
Hello @christospappas, what is the reason that you have closed this ticket? I think his would be a very useful feature, i know this is extremely hard to do it right with lots of lookup and potential need for multiple indexes, Perhaps, a intelligent ID
this will mean if you have liked, dislike, then liked something, it would stop the dup activities |
Currently i have implemented a very naive way to lookup existing activity for same verb, actor, object and receiver ids, unfortunately, i am not sure how to do the deep array lookup of receivers by ids. so here is my attempt ## Todo: look into more effectient lookup
receivers_array = receivers.map { |r| { :id => r.id, :type => r.class.to_s } }
existing = Activity.where('verb'=> action, 'actor.id' => self.id, 'object.id' => object.id, 'receivers' => receivers_array).first
Activity.publish(action, actor: self, object: object, receivers: receivers) unless existing Look up within a time existing = Activity.where('verb'=> action, 'actor.id' => self.id, 'object.id' => object.id, :'created_at'.gt => 1.hour.ago).first
Activity.publish(action, actor: self, object: object, receivers: receivers) unless existing or please advice more efficient methods |
Hi @speedmax, It would be good to add this feature... I closed it a while back due to not having the time to work on it further. It seems like there is a bit of interest in this gem lately so I should probably get back into maintaining it. Your code above could work, however if you have a large number of receivers I don't think it'll perform very well. Not sure if creating a hash for all the values is a good idea either. I'm planning on changing the gems schema so that it can scale better with sharding (@joe1chen has a fork that does this) I just haven't had time to pull and clean it up. With this schema change, it'll means activities will be duplicated for each receiver. That will make finding duplicates even more difficult. I'll re-open and have a look at it some more when I get time. If you work out an efficient way to do it send through a pull request and i'll add you as a contributor. |
duplicate of issue #25 |
Add the option to check whether the same activity has recently been made, if it has then update the timestamp, otherwise create a new activity.
The text was updated successfully, but these errors were encountered: