-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove old NosNotification objects #765
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome! Glad you found and removed some unnecessary code, too!
return fetchRequest | ||
} | ||
|
||
static func cutoffDate() -> Date { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is named very similarly to PushNotificationService.notificationCutoff
but performs a slightly different function which I think I will find confusing in the future.
NosNotification.cutoffDate()
is two months beforeDate.now
, and is used to delete old notifications from the db.PushNotificationService.notificationCutoff
is used to limit which notifications are displayed to the user as push notifications. When the user first opens the app it is initialized to Date.now. This is to prevent us showing tons of push notifications on first login. Then after that it is set to the date of the last notification that we showed.
Could we make these names more specific and maybe document the two vars? I think this one could be staleNotificationCutoff
and the other could be showPushNotificationsAfter
, but I'm open to other ideas too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed the remaining feedback and I'm approving my own work since no one else is working this week.
#424
The idea is as follows, we delete all notifications before a specific cutoff date (I set it to two months earlier than now) and, also, we don't create notifications before that cutoff date. These notifications are still displayed in the notifications view because that view is populated differently, with a request to Event table.
The NosNotification model didn't have a date to use for that nor a reference to the event (that could be nullified if the event is removed), so I edited the coredatamodel to add a createdDate for the NosNotification and matched it to the date of the event.
I removed an unused function I found as well.