hopefully fix issue where voting is filled in with missing when its time to vote

This commit is contained in:
Trey t
2022-03-05 11:28:29 -06:00
parent 012fcc43d5
commit d56e74053e
13 changed files with 168 additions and 105 deletions

View File

@@ -35,7 +35,7 @@ extension PersistenceController {
let entries = try! viewContext.fetch(fetchRequest)
if let firstEntry = entries.last?.forDate {
let allDates: [Date] = Date.dates(from: firstEntry, to: endDate).map({
let allDates: [Date] = Date.dates(from: firstEntry, toDate: endDate, includingToDate: true).map({
let zeroDate = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: $0)!
return zeroDate
})

View File

@@ -19,4 +19,14 @@ extension PersistenceController {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
}
func deleteLast(numberOfEntries: Int) {
let entries = PersistenceController.shared.getData(startDate: Calendar.current.date(byAdding: .day, value: -numberOfEntries, to: Date())!,
endDate: Date(),
includedDays: [])
for entry in entries {
viewContext.delete(entry)
}
try! viewContext.save()
}
}