How to Clean Old Activities

86 views
Skip to first unread message

Mustafa Serhat Dündar

unread,
Jan 5, 2015, 5:42:54 PM1/5/15
to public-...@googlegroups.com
Hi,

I'm wondering about how to clean up old activities from database without breaking relations?

Thanks in advance.

Jakub Okoński

unread,
Jan 5, 2015, 5:45:26 PM1/5/15
to Mustafa Serhat Dündar, public-...@googlegroups.com
All the relations are stored in the activity (https://github.com/pokonski/public_activity/blob/master/lib/public_activity/orm/active_record/activity.rb#L10-L15), so it should be enough just to delete them

--
You received this message because you are subscribed to the Google Groups "Public Activity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to public-activi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mustafa Serhat Dündar

unread,
Jan 5, 2015, 5:57:22 PM1/5/15
to Jakub Okoński, public-...@googlegroups.com
I have never used polymorphic relations so I had a suspicion about deleting old records. I tried;

> Activity.last
> PublicActivity.last

from the rails console but couldn't get records for deleting. Can you please give an example of deleting activities which are older than 1 year?

Thanks.


--

Jakub Okoński

unread,
Jan 5, 2015, 7:29:38 PM1/5/15
to Mustafa Serhat Dündar, public-...@googlegroups.com
The model is at `PublicActivity::Activity`, so try something like `PublicActivity::Activity.where('created_at < ?', 1.year.ago)`.
Reply all
Reply to author
Forward
0 new messages