This commit is contained in:
2021-08-02 22:28:30 +00:00
parent 5ecf1a2620
commit f522dda8f1
9 changed files with 104 additions and 41 deletions

View File

@@ -8,8 +8,7 @@ namespace AyaNova.Biz
{
/// <summary>
/// Clean up notification system, keep items down to 90 days
///
/// Clear out old data no longer required for notification system
/// </summary>
internal static class CoreNotificationSweeper
{
@@ -32,8 +31,8 @@ namespace AyaNova.Biz
log.LogTrace("Sweep starting");
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
{
//Notification (App notifications table) - deletes all APP notifications older than 90 days (if they want to keep it then can turn it into a reminder or SAVE it somehow)
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotification where created < {dtDeleteCutoff}");
//Notification (in-App notifications table) - deletes all APP notifications older than 90 days (if they want to keep it then can turn it into a reminder or SAVE it somehow)
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from ainappnotification where created < {dtDeleteCutoff}");
//NotifyEvent - deletes any notifyevent with no event date created more than 90 days ago
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotifyevent where eventdate is null and created < {dtDeleteCutoff}");
@@ -42,7 +41,7 @@ namespace AyaNova.Biz
//then deletes it if created more than 90 days ago (pretty sure there are no back dated events, once it's passed it's past)
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotifyevent where eventdate < {dtPastEventCutoff} and created < {dtDeleteCutoff}");
//NotifyDeliveryLog - deletes all log items older than 90 days
//NotifyDeliveryLog - deletes all log items older than 90 days (NOTE: this log is also used to identify and prevent high frequency repetitive dupes)
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from anotifydeliverylog where processed < {dtDeleteCutoff}");
}