forked from agzam/vyatsu-schedule
fix: FOREIGN KEY constraint failed
This commit is contained in:
@@ -112,11 +112,8 @@ class ScheduleRepositoryImpl(
|
||||
private suspend fun replaceDays(scheduleId: Long, days: List<Day>) {
|
||||
scheduleDao.deleteDaysForSchedule(scheduleId)
|
||||
val dayEntities = days.map { DayEntity(scheduleId = scheduleId, date = it.date.toEpochDay()) }
|
||||
val dayIdByDate = mutableMapOf<LocalDate, Long>()
|
||||
scheduleDao.insertDays(dayEntities)
|
||||
for (day in dayEntities) {
|
||||
dayIdByDate[LocalDate.ofEpochDay(day.date)] = day.id
|
||||
}
|
||||
val dayIds = scheduleDao.insertDays(dayEntities)
|
||||
val dayIdByDate = dayEntities.zip(dayIds).associate { (day, id) -> LocalDate.ofEpochDay(day.date) to id }
|
||||
val lessons = days.flatMap { day ->
|
||||
day.intervals.flatMapIndexed { slotIndex, slot ->
|
||||
slot.lessons.mapIndexed { lessonIndex, lesson ->
|
||||
|
||||
Reference in New Issue
Block a user