forked from agzam/vyatsu-schedule
refactor: database multi-period schedule storage
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
package agzam.vyatsu.domain.model
|
||||
|
||||
/**
|
||||
* Расписание группы, как правило содержит 2 недели
|
||||
* @author Agzam
|
||||
*/
|
||||
import java.time.LocalDate
|
||||
|
||||
data class SchedulePeriod(
|
||||
val weekStart: LocalDate,
|
||||
val weekEnd: LocalDate,
|
||||
val season: Season
|
||||
)
|
||||
|
||||
data class Schedule(
|
||||
|
||||
val groupId: String,
|
||||
val season: Season,
|
||||
|
||||
/** Может содержать более 7 дней */
|
||||
val periods: List<SchedulePeriod>,
|
||||
val days: List<Day>
|
||||
|
||||
) {
|
||||
|
||||
fun periodOf(date: LocalDate): SchedulePeriod? =
|
||||
periods.firstOrNull { !date.isBefore(it.weekStart) && !date.isAfter(it.weekEnd) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package agzam.vyatsu.domain.repository
|
||||
|
||||
import agzam.vyatsu.domain.model.Schedule
|
||||
import agzam.vyatsu.domain.model.SchedulePeriod
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface ScheduleRepository {
|
||||
@@ -8,5 +9,6 @@ interface ScheduleRepository {
|
||||
suspend fun getSchedule(groupId: String): Schedule?
|
||||
suspend fun sync(groupId: String): Schedule?
|
||||
suspend fun isStale(groupId: String): Boolean
|
||||
suspend fun clear(groupId: String)
|
||||
suspend fun clearPeriod(groupId: String, period: SchedulePeriod)
|
||||
suspend fun clearAll(groupId: String)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user