BUGFIX: double entries for almanachse

This commit is contained in:
Simon Martens
2026-01-24 22:14:39 +01:00
parent 5d75934c37
commit cc1f1a8473
13 changed files with 2174 additions and 1953 deletions

View File

@@ -15,6 +15,7 @@ func RecordsFromRelationBändeReihen(
entries map[int]*dbmodels.Entry,
) ([]*dbmodels.REntriesSeries, error) {
records := make([]*dbmodels.REntriesSeries, 0, len(relations.Relationen))
seen := make(map[string]int)
collection, err := app.FindCollectionByNameOrId(dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.SERIES_TABLE))
if err != nil {
app.Logger().Error("Error finding collection", "error", err, "collection", dbmodels.RelationTableName(dbmodels.ENTRIES_TABLE, dbmodels.SERIES_TABLE))
@@ -62,10 +63,30 @@ func RecordsFromRelationBändeReihen(
ser := record.Series()
if strings.TrimSpace(rel) == "" || strings.TrimSpace(ent) == "" || strings.TrimSpace(ser) == "" {
entry.SetEditState(dbmodels.EDITORSTATE_VALUES[len(dbmodels.EDITORSTATE_VALUES)-2])
appendEntryComment(entry, "Unvollständige Relation BandReihe; bitte prüfen.")
_ = app.Save(entry)
}
key := entry.Id + "|" + series.Id
if idx, ok := seen[key]; ok {
existing := records[idx]
if existing.Type() == "Bevorzugter Reihentitel" {
appendEntryComment(entry, "Doppelte Relation BandReihe entfernt; bitte prüfen.")
_ = app.Save(entry)
continue
}
if record.Type() == "Bevorzugter Reihentitel" {
records[idx] = record
appendEntryComment(entry, "Doppelte Relation BandReihe entfernt; bitte prüfen.")
_ = app.Save(entry)
continue
}
appendEntryComment(entry, "Doppelte Relation BandReihe entfernt; bitte prüfen.")
_ = app.Save(entry)
continue
}
seen[key] = len(records)
records = append(records, record)
}