Skip to content
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

Merged
merged 8 commits into from
Jan 10, 2024
Merged

Conversation

martindsq
Copy link
Member

#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.

@martindsq martindsq requested a review from mplorentz December 22, 2023 20:31
Copy link
Contributor

@joshuatbrown joshuatbrown left a 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!

Nos/Models/NosNotification+CoreDataClass.swift Outdated Show resolved Hide resolved
Nos/Models/NosNotification+CoreDataClass.swift Outdated Show resolved Hide resolved
return fetchRequest
}

static func cutoffDate() -> Date {
Copy link
Member

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 before Date.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.

Copy link
Member

@mplorentz mplorentz left a 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.

@mplorentz mplorentz merged commit da6478a into main Jan 10, 2024
4 checks passed
@mplorentz mplorentz deleted the cleanup/nos_notification branch January 10, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants