everything changed
This commit is contained in:
@@ -32,7 +32,8 @@ extension PersistenceController {
|
||||
}
|
||||
|
||||
func fillInMissingDates() {
|
||||
let endDate = ShowBasedOnVoteLogics.getLastDateVoteShouldExist()
|
||||
let currentOnboarding = UserDefaultsStore.getOnboarding()
|
||||
let endDate = ShowBasedOnVoteLogics.getLastDateVoteShouldExist(onboardingData: currentOnboarding)
|
||||
|
||||
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "forDate", ascending: false)]
|
||||
|
||||
@@ -73,13 +73,12 @@ extension PersistenceController {
|
||||
var components = DateComponents()
|
||||
components.month = month
|
||||
components.year = year
|
||||
components.day = 1
|
||||
let startDateOfMonth = Calendar.current.date(from: components)!
|
||||
|
||||
let items = data.filter({ entry in
|
||||
let components = calendar.dateComponents([.month, .year], from: startDateOfMonth)
|
||||
let entryComponents = calendar.dateComponents([.month, .year], from: entry.forDate!)
|
||||
return (components.month == entryComponents.month && components.year == entryComponents.year)
|
||||
})
|
||||
let items = PersistenceController.shared.getData(startDate: startDateOfMonth,
|
||||
endDate: startDateOfMonth.endOfMonth,
|
||||
includedDays: [1,2,3,4,5,6,7])
|
||||
if !items.isEmpty {
|
||||
allMonths[month] = items
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ extension PersistenceController {
|
||||
}
|
||||
}
|
||||
|
||||
func generateObjectNotInArray() -> MoodEntry {
|
||||
func generateObjectNotInArray(forDate date: Date = Date(), withMood mood: Mood = .placeholder) -> MoodEntry {
|
||||
let newItem = MoodEntry(context: childContext)
|
||||
newItem.timestamp = Date()
|
||||
newItem.moodValue = Int16(Mood.placeholder.rawValue)
|
||||
newItem.forDate = Date()
|
||||
newItem.moodValue = Int16(mood.rawValue)
|
||||
newItem.forDate = date
|
||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: Date()))
|
||||
newItem.canEdit = false
|
||||
newItem.canDelete = false
|
||||
|
||||
Reference in New Issue
Block a user