From e31b6120806240ece82426fe0a4d38c14113e464 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 23 Jul 2026 13:56:42 +0200 Subject: liturgy: LoadOffline sets PartID (fix offline gospel-only) --- internal/liturgy/store.go | 7 ++++++- internal/liturgy/store_test.go | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/liturgy/store.go b/internal/liturgy/store.go index 0dc8016..6762585 100644 --- a/internal/liturgy/store.go +++ b/internal/liturgy/store.go @@ -168,8 +168,13 @@ func LoadOffline(date string) ([]Section, error) { return nil, fmt.Errorf("%s not harvested; run 'lectio update' while online first", date) } secs := make([]Section, 0, len(rows)) + czytanieCount := 0 for _, r := range rows { - secs = append(secs, Section{Heading: r.label, Citation: r.citation}) + secs = append(secs, Section{ + Heading: r.label, + Citation: r.citation, + PartID: partID(r.label, &czytanieCount), + }) } return secs, nil } diff --git a/internal/liturgy/store_test.go b/internal/liturgy/store_test.go index 979b091..08fd1a1 100644 --- a/internal/liturgy/store_test.go +++ b/internal/liturgy/store_test.go @@ -31,12 +31,19 @@ func TestHarvestAndOffline(t *testing.T) { t.Fatal(err) } var haveGospel bool + var haveFirstCzytanie bool for _, s := range secs { - if s.Citation == "J 20, 1. 11-18" { + if s.Citation == "J 20, 1. 11-18" && s.PartID == "ewangelia" { haveGospel = true } + if strings.HasPrefix(s.Heading, "1. czytanie") && s.PartID == "pierwsze_czytanie" { + haveFirstCzytanie = true + } } if !haveGospel { - t.Error("offline gospel citation missing") + t.Error("offline gospel citation or PartID missing") + } + if !haveFirstCzytanie { + t.Error("offline first czytanie PartID missing") } } -- cgit v1.3