Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

remove hardcoded date

roryclearf39975ee06f0
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.m
index 437b914..93fcf7c 100644
--- a/clearcam/FileServer.m
+++ b/clearcam/FileServer.m
@@ -86,7 +86,7 @@
// Fetch the DayEntity for the given date
NSFetchRequest *dayFetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"DayEntity"];
- dayFetchRequest.predicate = [NSPredicate predicateWithFormat:@"date == %@", @"2025-02-13"];
+ dayFetchRequest.predicate = [NSPredicate predicateWithFormat:@"date == %@", dateParam];
NSArray *fetchedDays = [backgroundContext executeFetchRequest:dayFetchRequest error:&error];
@@ -96,7 +96,7 @@
}
if (fetchedDays.count == 0) {
- NSLog(@"No DayEntity found for date 2025-02-13");
+ NSLog(@"No DayEntity found for date %@",dateParam);
return;
}
@@ -169,7 +169,7 @@
// Log the results
NSLog(@"rory length of init segments = %lu", (unsigned long)tempSegmentDicts.count);
- NSLog(@"Fetched and processed %lu segments for date 2025-02-13", (unsigned long)tempSegmentDicts.count);
+ NSLog(@"Fetched and processed %lu segments for date %@", (unsigned long)tempSegmentDicts.count,dateParam);
}];
}
diff --git a/clearcam/ViewController.m b/clearcam/ViewController.m
index ef1b7d6..3b8ccfb 100644
--- a/clearcam/ViewController.m
+++ b/clearcam/ViewController.m
@@ -369,8 +369,11 @@ NSMutableDictionary *classColorMap;
NSError *error = nil;
// Fetch or create DayEntity
+ NSDateFormatter *formatter = [NSDateFormatter new];
+ formatter.dateFormat = @"yyyy-MM-dd";
+ NSString *dateParam = [formatter stringFromDate:[NSDate date]];
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"DayEntity"];
- fetchRequest.predicate = [NSPredicate predicateWithFormat:@"date == %@", @"2025-02-13"];
+ fetchRequest.predicate = [NSPredicate predicateWithFormat:@"date == %@", dateParam];
NSArray *fetchedDays = [backgroundContext executeFetchRequest:fetchRequest error:&error];
NSManagedObject *dayEntity;
@@ -378,7 +381,7 @@ NSMutableDictionary *classColorMap;
dayEntity = fetchedDays.firstObject;
} else {
dayEntity = [NSEntityDescription insertNewObjectForEntityForName:@"DayEntity" inManagedObjectContext:backgroundContext];
- [dayEntity setValue:@"2025-02-13" forKey:@"date"];
+ [dayEntity setValue:dateParam forKey:@"date"];
}
// Create new SegmentEntity
@@ -433,7 +436,7 @@ NSMutableDictionary *classColorMap;
if (![backgroundContext save:&error]) {
NSLog(@"Failed to save segment: %@", error.localizedDescription);
} else {
- NSLog(@"Segment saved successfully under DayEntity with date 2025-02-13.");
+ NSLog(@"Segment saved successfully under DayEntity with date %@",dateParam);
// Merge changes back to the main context
[self.fileServer.context performBlock:^{