fix
This commit is contained in:
@@ -183,9 +183,9 @@ func ScoreV1ProcessCompletedItem(item V1ProcessJobItem, opts ScoreV1ProcessItemO
|
||||
}
|
||||
|
||||
// EnforceV1ProcessCompletedItem fills LegacyProcessItem projection gaps for a
|
||||
// successful item: plain nonempty description when title exists, meta_*, clean
|
||||
// attributes, eprel object|null, and image key shapes. Category must already be
|
||||
// set by the caller when mapped provides a unique_id.
|
||||
// successful item: nonempty description when title exists (formula HTML
|
||||
// preserved), meta_*, clean attributes, eprel object|null, and image key shapes.
|
||||
// Category must already be set by the caller when mapped provides a unique_id.
|
||||
//
|
||||
// allowed is the company attribute_key set (canonicalized). When nil, only
|
||||
// coreCharacteristicAttrKeys are kept (never leak feed junk like zavora).
|
||||
@@ -224,8 +224,9 @@ func EnforceV1ProcessCompletedItem(item V1ProcessJobItem, language string, allow
|
||||
catLabel = cat
|
||||
}
|
||||
|
||||
desc, _ := plainDescriptionFromItem(item)
|
||||
desc, _ := descriptionFromItem(item)
|
||||
// Empty, weak, or title-echo copy must be replaced — never leave description==title.
|
||||
// Formula HTML that satisfies multi-section templates is kept as-is.
|
||||
if title != "" && (desc == "" || isWeakPriorEnhanceDescription(desc, title) || descriptionEchoesTitle(desc, title)) {
|
||||
if synth := synthesizeDescriptionFromTitle(title, catLabel, language, attrs); synth != "" {
|
||||
desc = synth
|
||||
@@ -324,6 +325,38 @@ func stringFromItem(item V1ProcessJobItem, key string) string {
|
||||
return strings.TrimSpace(stringFromAny(item[key]))
|
||||
}
|
||||
|
||||
func descriptionFromItem(item V1ProcessJobItem) (string, bool) {
|
||||
if item == nil {
|
||||
return "", true
|
||||
}
|
||||
raw := item["description"]
|
||||
if raw == nil {
|
||||
return "", true
|
||||
}
|
||||
switch raw.(type) {
|
||||
case string:
|
||||
return DescriptionFromAny(raw), true
|
||||
case []any, []string:
|
||||
// Legacy mistake: description as array — coerce to string, keep HTML.
|
||||
if s := DescriptionFromAny(raw); s != "" {
|
||||
return s, true
|
||||
}
|
||||
return "", false
|
||||
case map[string]any:
|
||||
if s := DescriptionFromAny(raw); s != "" {
|
||||
return s, true
|
||||
}
|
||||
return "", false
|
||||
default:
|
||||
s := strings.TrimSpace(fmt.Sprint(raw))
|
||||
if s == "" || s == "<nil>" {
|
||||
return "", true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// plainDescriptionFromItem is kept for callers that need SEO/plain text (meta).
|
||||
func plainDescriptionFromItem(item V1ProcessJobItem) (string, bool) {
|
||||
if item == nil {
|
||||
return "", true
|
||||
@@ -336,7 +369,6 @@ func plainDescriptionFromItem(item V1ProcessJobItem) (string, bool) {
|
||||
case string:
|
||||
return PlainDescriptionFromAny(raw), true
|
||||
case []any, []string:
|
||||
// Legacy mistake: description as array — convert to plain string.
|
||||
if s := PlainDescriptionFromAny(raw); s != "" {
|
||||
return s, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user