refactor(notifications): update supporting classes for new timestamp model

- Remove setFetchTime() calls from DailyNotificationFetchWorker
- Remove setFetchTime() calls from DailyNotificationFetcher
- Update DailyNotificationMaintenanceWorker to use getFetchedAt()
- Update DailyNotificationMigration to use getFetchedAt()
- Align all classes with immutable fetchedAt timestamp approach
- Ensure consistent timestamp handling across the codebase

These changes support the new timestamp model where fetchedAt
is immutable and set at object creation time.
This commit is contained in:
Matthew Raymer
2025-10-14 06:16:57 +00:00
parent 92c843b07e
commit 0d2be9619d
4 changed files with 8 additions and 8 deletions

View File

@@ -385,7 +385,7 @@ public class DailyNotificationFetchWorker extends Worker {
content.setId("timesafari_fallback_" + System.currentTimeMillis()); content.setId("timesafari_fallback_" + System.currentTimeMillis());
content.setTitle("TimeSafari Update Available"); content.setTitle("TimeSafari Update Available");
content.setBody("Your community updates are ready. Tap to view offers, projects, and connections."); content.setBody("Your community updates are ready. Tap to view offers, projects, and connections.");
content.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
content.setScheduledTime(System.currentTimeMillis() + 30000); // 30 seconds from now content.setScheduledTime(System.currentTimeMillis() + 30000); // 30 seconds from now
return content; return content;
@@ -448,7 +448,7 @@ public class DailyNotificationFetchWorker extends Worker {
fallbackContent.setSound(lastContent.isSound()); fallbackContent.setSound(lastContent.isSound());
fallbackContent.setPriority(lastContent.getPriority()); fallbackContent.setPriority(lastContent.getPriority());
fallbackContent.setUrl(lastContent.getUrl()); fallbackContent.setUrl(lastContent.getUrl());
fallbackContent.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
return fallbackContent; return fallbackContent;
} }
@@ -474,7 +474,7 @@ public class DailyNotificationFetchWorker extends Worker {
content.setTitle("Daily Update"); content.setTitle("Daily Update");
content.setBody("🌅 Good morning! Ready to make today amazing?"); content.setBody("🌅 Good morning! Ready to make today amazing?");
content.setScheduledTime(scheduledTime); content.setScheduledTime(scheduledTime);
content.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
content.setPriority("default"); content.setPriority("default");
content.setSound(true); content.setSound(true);

View File

@@ -223,7 +223,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update"); content.setTitle("Daily Update");
content.setBody("Your daily notification is ready"); content.setBody("Your daily notification is ready");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
return content; return content;
@@ -250,7 +250,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update"); content.setTitle("Daily Update");
content.setBody("Your daily notification is ready"); content.setBody("Your daily notification is ready");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
Log.d(TAG, "Network response parsed successfully"); Log.d(TAG, "Network response parsed successfully");
return content; return content;
@@ -296,7 +296,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update"); content.setTitle("Daily Update");
content.setBody("🌅 Good morning! Ready to make today amazing?"); content.setBody("🌅 Good morning! Ready to make today amazing?");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis()); // fetchedAt is set in constructor, no need to set it again
content.setPriority("default"); content.setPriority("default");
content.setSound(true); content.setSound(true);

View File

@@ -327,7 +327,7 @@ public class DailyNotificationMaintenanceWorker extends Worker {
return false; return false;
} }
if (notification.getFetchTime() <= 0) { if (notification.getFetchedAt() <= 0) {
Log.w(TAG, "Data integrity issue: Invalid fetch time"); Log.w(TAG, "Data integrity issue: Invalid fetch time");
return false; return false;
} }

View File

@@ -177,7 +177,7 @@ public class DailyNotificationMigration {
values.put(DailyNotificationDatabase.COL_CONTENTS_PAYLOAD_JSON, values.put(DailyNotificationDatabase.COL_CONTENTS_PAYLOAD_JSON,
gson.toJson(notification)); gson.toJson(notification));
values.put(DailyNotificationDatabase.COL_CONTENTS_FETCHED_AT, values.put(DailyNotificationDatabase.COL_CONTENTS_FETCHED_AT,
notification.getFetchTime()); notification.getFetchedAt());
// ETag is null for migrated data // ETag is null for migrated data
values.putNull(DailyNotificationDatabase.COL_CONTENTS_ETAG); values.putNull(DailyNotificationDatabase.COL_CONTENTS_ETAG);