autogen cached models

This commit is contained in:
2026-05-23 00:24:47 +02:00
parent a17477cff1
commit 82bd075ae4
6 changed files with 146 additions and 1 deletions
+57
View File
@@ -96,6 +96,10 @@ func autogenConsumerTargetsCollectedDataset(collected []nativeCollectedDataset,
if dataset.Dataset.Name == "visualeffects" {
return true
}
case "cachedmodels_rows":
if dataset.Dataset.Name == "cachedmodels" {
return true
}
}
}
return false
@@ -603,6 +607,59 @@ func autogenPartsInventory(entries []autogenManifestEntry) map[string]map[int]st
return result
}
func augmentWithAutogeneratedCachedModels(collected []nativeCollectedDataset, entries []autogenManifestEntry) ([]nativeCollectedDataset, error) {
if len(entries) == 0 {
return collected, nil
}
result := append([]nativeCollectedDataset(nil), collected...)
for i, dataset := range result {
if dataset.Dataset.Name != "cachedmodels" {
continue
}
if !slices.Contains(dataset.Columns, "Model") {
return nil, fmt.Errorf("cachedmodels dataset must include Model column for cachedmodels_rows autogen")
}
rows := make([]map[string]any, len(dataset.Rows), len(dataset.Rows)+len(entries))
seenModels := make(map[string]struct{}, len(dataset.Rows)+len(entries))
nextID := 0
for index, row := range dataset.Rows {
cloned := cloneRowMap(row)
rows[index] = cloned
if rowID, ok := cloned["id"].(int); ok && rowID >= nextID {
nextID = rowID + 1
}
if model, ok := cloned["Model"].(string); ok {
model = strings.TrimSpace(model)
if model != "" && model != nullValue {
seenModels[strings.ToLower(model)] = struct{}{}
}
}
}
for _, entry := range entries {
model := strings.TrimSpace(entry.ModelStem)
if model == "" {
continue
}
key := strings.ToLower(model)
if _, exists := seenModels[key]; exists {
continue
}
rows = append(rows, map[string]any{
"id": nextID,
"Model": model,
})
seenModels[key] = struct{}{}
nextID++
}
result[i].Rows = rows
}
return result, nil
}
func augmentWithAutogeneratedHeadVisualeffects(collected []nativeCollectedDataset, entries []autogenManifestEntry) ([]nativeCollectedDataset, error) {
if len(entries) == 0 {
return collected, nil