closed #16
This commit is contained in:
@@ -74,12 +74,22 @@ struct PersistenceController {
|
||||
return last ?? nil
|
||||
}
|
||||
|
||||
public func getData(startDate: Date, endDate: Date) -> [MoodEntry] {
|
||||
let predicate = NSPredicate(format: "%K >= %@ && %K <= %@",
|
||||
public func getData(startDate: Date, endDate: Date, includedDays: [Int]) -> [MoodEntry] {
|
||||
var includedDays16 = [Int16]()
|
||||
|
||||
if includedDays.isEmpty {
|
||||
includedDays16 = [Int16(1), Int16(2), Int16(3), Int16(4), Int16(5), Int16(6), Int16(7)]
|
||||
} else {
|
||||
includedDays16 = includedDays.map({
|
||||
Int16($0)
|
||||
})
|
||||
}
|
||||
let predicate = NSPredicate(format: "%K >= %@ && %K <= %@ && weekDay IN %@",
|
||||
"forDate",
|
||||
startDate as NSDate,
|
||||
"forDate",
|
||||
endDate as NSDate)
|
||||
endDate as NSDate,
|
||||
includedDays16)
|
||||
|
||||
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
||||
fetchRequest.predicate = predicate
|
||||
|
||||
Reference in New Issue
Block a user