Static files handling

This commit is contained in:
Simon Martens
2025-02-11 21:35:40 +01:00
parent 0c8cd35577
commit 71dcf9bf5e
9 changed files with 50 additions and 107 deletions

View File

@@ -15,6 +15,7 @@ import (
func RecordsFromBände(
app core.App,
adb xmlmodels.AccessDB,
places map[string]*dbmodels.Place,
) ([]*dbmodels.Entry, error) {
collection, err := app.FindCollectionByNameOrId(dbmodels.ENTRIES_TABLE)
records := make([]*dbmodels.Entry, 0, len(adb.Bände.Bände))
@@ -74,7 +75,7 @@ func RecordsFromBände(
handlePreferredTitleEntry(record, band, rmap, relmap)
handleDeprecated(record, band)
handleOrte(record, band, omap, app, ocoll)
handleOrte(record, band, omap, app, ocoll, places)
records = append(records, record)
}
@@ -122,6 +123,7 @@ func handleOrte(
orte map[string]xmlmodels.Ort,
app core.App,
ocollection *core.Collection,
places map[string]*dbmodels.Place,
) {
for _, v := range band.Orte {
o, ok := orte[v.Value]
@@ -133,8 +135,8 @@ func handleOrte(
e = true
}
ort, err := app.FindFirstRecordByData(dbmodels.PLACES_TABLE, dbmodels.PLACES_NAME_FIELD, n)
if err == nil {
ort, ok := places[n]
if ok {
before := record.Places()
record.SetPlaces(append(before, ort.Id))
} else {

View File

@@ -16,6 +16,7 @@ func ItemsFromBändeAndBIBLIO(
app core.App,
entries xmlmodels.Bände,
biblio map[int]xmlmodels.BIBLIOEintrag,
entriesmap map[string]*dbmodels.Entry,
) ([]*dbmodels.Item, error) {
collection, err := app.FindCollectionByNameOrId(dbmodels.ITEMS_TABLE)
records := make([]*dbmodels.Item, 0, len(entries.Bände))
@@ -27,9 +28,9 @@ func ItemsFromBändeAndBIBLIO(
for i := 0; i < len(entries.Bände); i++ {
band := entries.Bände[i]
banddb, err := app.FindFirstRecordByData(dbmodels.ENTRIES_TABLE, dbmodels.MUSENALMID_FIELD, band.ID)
if err != nil {
app.Logger().Error("Error finding record", "error", err, "collection", dbmodels.ENTRIES_TABLE, "field", dbmodels.MUSENALMID_FIELD, "value", band.ID)
banddb, ok := entriesmap[band.ID]
if !ok {
app.Logger().Error("Error finding entry", "error", err, "entry", band.ID)
continue
}