[buddypress-trac] [BuddyPress Trac] #7534: Remove read notifications from the DB table after a specified time period

buddypress-trac noreply at wordpress.org
Sat Jan 27 19:39:52 UTC 2018


#7534: Remove read notifications from the DB table after a specified time period
------------------------------------+------------------
 Reporter:  r-a-y                   |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  3.0
Component:  Performance             |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |
------------------------------------+------------------
Changes (by r-a-y):

 * keywords:  dev-feedback => dev-feedback has-patch


Comment:

 `01.patch` is an attempt to remove read notifications older than 30 days.

 Patch does the following:
 - Fixes notification date queries(!).  We were referencing the wrong date
 column in the `BP_Notifications_Notification::get_date_query_sql()`
 method.
 - Introduces a cronjob to delete stale notifications every week -
 `bp_notifications_cron()`.  Can probably add a filter to change the
 interval if desired.
 - Introduces a utility function to delete stale notifications -
 `bp_notifications_delete_stale()`.  This function deletes stale
 notifications older than 30 days, 2000 items at a time by default.  If
 there are more stale notifications to remove, the function runs
 recursively until all stale notifications are removed.
 - Adds a new method to delete multiple notifications by ID -
 `BP_Notifications_Notification::delete_by_ids()`.  I couldn't use the
 existing `delete()` method as it can only delete one notification at a
 time, which can be a hassle when deleting a ton of notifications at once.

 Let me know what you think.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7534#comment:5>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list