Fix class teacher full-day absence classification
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-10-08 11:20:17 +02:00
1 parent e4a81e8974
commit a3cd57e5d8
7 files changed
+73 -2

No files matched your search

@@ -34,6 +34,7 @@ public sealed class UntisReportCacheService(
{
private static readonly TimeSpan HotWindowRefreshInterval = TimeSpan.FromHours(1);
private const int HotWindowDays = 14;
private const int AbsenceReportVersion = 1;
/// Roster hat anders als Fehlzeiten/Klassenbuch keine Historie (nur "aktueller Stand einer
/// Klasse") - deshalb ohne heißes/kaltes Fenster, nur "gilt der letzte Abruf noch als frisch".
@@ -66,6 +67,10 @@ public sealed class UntisReportCacheService(
DateOnly start, DateOnly end, bool forceRefresh = false, CancellationToken token = default)
{
var state = fetchState.Get(className, UntisCacheKind.Absences);
// Ältere Berichte haben Tage mit einzelnen Fehlstunden als Fehltage geliefert.
// Auch die dauerhaft gecachte Historie muss mit der Trennung neu geladen werden.
if (state is not null && state.AbsenceReportVersion != AbsenceReportVersion)
state = new UntisCacheFetchState { Id = state.Id, ClassName = className, Kind = UntisCacheKind.Absences };
var plan = Plan(state, start, end, Today(), forceRefresh, DateTime.UtcNow);
if (plan.RefreshHotWindow)
@@ -76,7 +81,7 @@ public sealed class UntisReportCacheService(
if (plan.FetchColdRange)
{
var older = await untis.GetClassAbsencesAsync(className, plan.ColdRangeStart, plan.ColdRangeEnd, token);
absenceCache.InsertRange(older.Select(ToEntry));
absenceCache.ReplaceRange(className, Int(plan.ColdRangeStart), Int(plan.ColdRangeEnd), older.Select(ToEntry));
}
if (plan.RefreshHotWindow || plan.FetchColdRange)
fetchState.Save(NextState(state, className, UntisCacheKind.Absences, plan));
@@ -137,6 +142,7 @@ public sealed class UntisReportCacheService(
Id = previous?.Id ?? Guid.NewGuid(),
ClassName = className,
Kind = kind,
AbsenceReportVersion = kind == UntisCacheKind.Absences ? AbsenceReportVersion : 0,
HotWindowFetchedAt = plan.RefreshHotWindow ? DateTime.UtcNow : previous?.HotWindowFetchedAt,
ColdCoverageStartDate = plan.ResultingColdCoverageStartDate,
};