forked from agzam/vyatsu-schedule
fix(teacher): group day slots by real lesson start time
slotIndex is a per-department index of non-empty intervals, not a time. Merging all departments of a period by slotIndex and deriving the slot time from the first inserted lesson produced shifted times (e.g. Meltsov 10:00 shown at 11:45) depending on sync order. Group by lesson start minute instead so each department's real times are kept. Add debug logging for teacher schedule sync/build and debounce teacher search in picker.
This commit is contained in:
@@ -5,6 +5,7 @@ import agzam.vyatsu.domain.model.Day
|
||||
import agzam.vyatsu.domain.model.Lesson
|
||||
import agzam.vyatsu.domain.model.LessonType
|
||||
import agzam.vyatsu.domain.model.TimeSlot
|
||||
import android.util.Log
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.time.LocalDate
|
||||
@@ -13,6 +14,7 @@ import java.time.format.DateTimeFormatter
|
||||
|
||||
object TeacherScheduleParser {
|
||||
|
||||
private const val TAG = "TeacherParserDebug"
|
||||
private val DAY_REGEX = Regex("""^(понедельник|вторник|среда|четверг|пятница|суббота|воскресенье)\s+(\d{2}\.\d{2}\.\d{2})$""")
|
||||
private val INTERVAL_REGEX = Regex("""^(\d{2}:\d{2})-(\d{2}:\d{2})$""")
|
||||
private val GROUP_TOKEN = Regex("""(?<![\p{L}\p{N}])[А-ЯЁа-яё]{1,4}-\d{2,4}-\d{2}-\d{2}(?![\p{L}\p{N}])""")
|
||||
@@ -60,6 +62,21 @@ object TeacherScheduleParser {
|
||||
}
|
||||
}
|
||||
flushDay()
|
||||
Log.d(TAG, "parse: teachers=$teachers days=${days.size}")
|
||||
for (day in days) {
|
||||
Log.d(TAG, " parse ${day.date}: intervals=${day.intervals.size}")
|
||||
for (slot in day.intervals) {
|
||||
val mel = slot.lessons.filter { it.teacher == "Мельцов В.Ю." }
|
||||
val teachersInSlot = slot.lessons.map { it.teacher }.distinct()
|
||||
Log.d(
|
||||
TAG,
|
||||
" slot ${slot.start}-${slot.end} total=${slot.lessons.size} meltsov=${mel.size} teachers=$teachersInSlot"
|
||||
)
|
||||
mel.forEach { l ->
|
||||
Log.d(TAG, " mel: room=${l.room} group=${l.group} subj=${l.subject} type=${l.type} raw=${l.raw}")
|
||||
}
|
||||
}
|
||||
}
|
||||
return ParsedTeacherSchedule(teachers, days)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user