Template usage
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
)
|
||||
|
||||
const nullValue = "****"
|
||||
const internalPortraitModuleAuthoredKey = "__topdata_portrait_module_authored"
|
||||
|
||||
type nativeDataset struct {
|
||||
Kind nativeDatasetKind
|
||||
@@ -568,7 +569,7 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
}
|
||||
|
||||
nextID := nextAvailableID(usedIDs)
|
||||
applyModuleData := func(sourceLabel string, moduleData map[string]any) error {
|
||||
applyModuleData := func(sourceLabel string, moduleData map[string]any, allowPortraitMetadataInjection bool) error {
|
||||
if rawEntries, ok := moduleData["entries"]; ok {
|
||||
entries, ok := rawEntries.(map[string]any)
|
||||
if !ok {
|
||||
@@ -625,6 +626,9 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
}
|
||||
existing[field] = value
|
||||
}
|
||||
if allowPortraitMetadataInjection && rowHasPortraitMetadata(existing) {
|
||||
existing[internalPortraitModuleAuthoredKey] = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
rowID, ok := lockData[key]
|
||||
@@ -642,6 +646,9 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
rows = append(rows, row)
|
||||
rowByID[rowID] = row
|
||||
rowByKey[key] = row
|
||||
if allowPortraitMetadataInjection && rowHasPortraitMetadata(row) {
|
||||
row[internalPortraitModuleAuthoredKey] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,6 +754,9 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
}
|
||||
row[field] = value
|
||||
}
|
||||
if allowPortraitMetadataInjection && rowHasPortraitMetadata(row) {
|
||||
row[internalPortraitModuleAuthoredKey] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -757,7 +767,7 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
return nativeCollectedDataset{}, err
|
||||
}
|
||||
for _, module := range generatedModules {
|
||||
if err := applyModuleData(module.Name, module.Data); err != nil {
|
||||
if err := applyModuleData(module.Name, module.Data, false); err != nil {
|
||||
return nativeCollectedDataset{}, err
|
||||
}
|
||||
}
|
||||
@@ -771,7 +781,7 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
|
||||
if err != nil {
|
||||
return nativeCollectedDataset{}, err
|
||||
}
|
||||
if err := applyModuleData(path, moduleData); err != nil {
|
||||
if err := applyModuleData(path, moduleData, true); err != nil {
|
||||
return nativeCollectedDataset{}, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user