fix
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
|
||||
)
|
||||
|
||||
// AppendFormulaConstraints appends language-agnostic title/description formula
|
||||
@@ -118,6 +120,24 @@ func AppendDescriptionFormulaSystemOverride(systemTpl string, descriptionTemplat
|
||||
return systemTpl + "\n" + descriptionFormulaSystemOverride
|
||||
}
|
||||
|
||||
// descriptionSatisfiesFormula reports whether desc includes the HTML tags required
|
||||
// by categories.description_template sections. No formula → always true.
|
||||
func descriptionSatisfiesFormula(desc string, template any) bool {
|
||||
sections, ok := parseDescriptionFormulaSections(template)
|
||||
if !ok || len(sections) == 0 {
|
||||
return true
|
||||
}
|
||||
desc = strings.TrimSpace(desc)
|
||||
if desc == "" || desc == "<nil>" {
|
||||
return false
|
||||
}
|
||||
types := make([]string, 0, len(sections))
|
||||
for _, s := range sections {
|
||||
types = append(types, s.Type)
|
||||
}
|
||||
return !company.DescriptionMissingFormulaHTMLTags(desc, types)
|
||||
}
|
||||
|
||||
type titleFormulaElement struct {
|
||||
Type string `json:"type"`
|
||||
Value string `json:"value"`
|
||||
|
||||
Reference in New Issue
Block a user