Bug fix, über Präferenz hinazs besetzen

This commit is contained in:
concierge committed 2026-11-19 15:57:06 +01:00
1 parent a5d4251868
commit 4b88aca958
9 files changed
+162 -48

No files matched your search

+1 -1
View File
@@ -515,8 +515,8 @@ func CandidateSuggestions(
}
used := dayServices[person.ID+"|"+service.DateKey()]
if len(used) > 0 && !subsetOfSingle(used, service.ID) {
// Only explicit absences are hard blocks for manual assignments.
warnings = append(warnings, "bereits an diesem Tag")
blocked = true
}
total := totalCounts[person.ID]
+49
View File
@@ -159,6 +159,55 @@ func TestCandidateSuggestionsAllowPreferenceOverrides(t *testing.T) {
}
}
func TestCandidateSuggestionsAllowMaxLimitOverride(t *testing.T) {
service := ServiceOccurrence{
ID: "s2", ChurchID: "c1", Date: MustDate("2026-11-17"),
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
}
earlier := ServiceOccurrence{
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
}
person := Person{
ID: "p1", FirstName: "Anna", LastName: "Berg", Roles: []Role{RoleLector},
Active: true, MaxPerMonth: 1,
}
existing := []Assignment{{
ID: "a1", ServiceID: earlier.ID, PersonID: person.ID, Role: RoleLector,
}}
suggestions := CandidateSuggestions(service, RoleLector,
[]Person{person}, nil, existing, []ServiceOccurrence{earlier, service}, nil, nil)
if len(suggestions) != 1 || suggestions[0].Blocked || !suggestions[0].BeyondPreferences {
t.Fatalf("manual suggestions should allow exceeding the monthly limit with a warning, got %#v", suggestions)
}
}
func TestCandidateSuggestionsAllowSameDayConflict(t *testing.T) {
service := ServiceOccurrence{
ID: "s2", ChurchID: "c1", Date: MustDate("2026-11-16"),
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
}
earlier := ServiceOccurrence{
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
TimeMinutes: 9 * 60, Title: "Frühmesse", LectorsNeeded: 1,
}
person := Person{
ID: "p1", FirstName: "Anna", LastName: "Berg", Roles: []Role{RoleLector},
Active: true, MaxPerMonth: 6,
}
existing := []Assignment{{
ID: "a1", ServiceID: earlier.ID, PersonID: person.ID, Role: RoleLector,
}}
suggestions := CandidateSuggestions(service, RoleLector,
[]Person{person}, nil, existing, []ServiceOccurrence{earlier, service}, nil, nil)
if len(suggestions) != 1 || suggestions[0].Blocked {
t.Fatalf("only absences should hard-block manual suggestions, got %#v", suggestions)
}
if !StringContains(suggestions[0].Warnings, "bereits an diesem Tag") {
t.Fatalf("same-day conflict should still be warned about, got %#v", suggestions[0].Warnings)
}
}
func TestCandidateSuggestionsBlockAbsences(t *testing.T) {
service := ServiceOccurrence{
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),