Example #1
0
def initDays(config: {}) -> [Day]:
    days = [Day.fromDict(d) for d in load("days")]

    # DO NOT Remove old days. They are necessary to properly recreate the schedule for past days

    # Create new days to remain at 1000 day threshold (20 for debug)

    # dayCount = 1000 # Real
    dayCount = 100  # Debug
    daysToCreate = dayCount - len(days)
    if days:
        startDate = days[-1].date
    else:
        startDate = arrow.now().date()

    currentDate = arrow.get(startDate)

    # Check if the current day is missing and add it if necessary
    for day in days:
        if day.date == currentDate.date():
            break
    else:
        days.append(Day(currentDate.date(), [], []))

    # Fill up days to get up to dayCount
    for _ in range(daysToCreate):
        currentDate = currentDate.shift(days=1)
        newDay = Day(currentDate.date(), [], [])
        days.append(newDay)

    # Load config-TimeSlots onto days if they don't exist already
    for day in days:
        initDay(day, config)  # Adds temporary timeslots based on config

    return days
Example #2
0
 def fromDict(valueDict: {}, globalTasks: [Task]):
     created, lastWorkConfirmed, scheduleDays = util.dateTimeStringToArrow(valueDict["created"]), util.dateTimeStringToArrow(valueDict["lastWorkConfirmed"]), valueDict["scheduleDays"]
     days = [Day.fromDict(scheduleDayDict, globalTasks=globalTasks) for scheduleDayDict in scheduleDays]
     return Schedule(days, lastWorkConfirmed, created=created)