Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-13 16:48:11 +03:00
parent b9322cda2f
commit 899b9fc7cc

View File

@@ -77,6 +77,22 @@ func firstThreeDigitToken(tokens []string) string {
return "" return ""
} }
func filePrimaryMatchesDim1(fileName, dim1 string) bool {
dim1 = strings.ToUpper(strings.TrimSpace(dim1))
if dim1 == "" {
return true
}
tokens := tokenizeImageFileName(fileName)
if len(tokens) == 0 {
return true
}
primary := firstThreeDigitToken(tokens)
if primary == "" {
return true
}
return primary == dim1
}
func imageFileMatches(fileName, dim1, dim3 string) bool { func imageFileMatches(fileName, dim1, dim3 string) bool {
dim1 = strings.ToUpper(strings.TrimSpace(dim1)) dim1 = strings.ToUpper(strings.TrimSpace(dim1))
dim3 = strings.ToUpper(strings.TrimSpace(dim3)) dim3 = strings.ToUpper(strings.TrimSpace(dim3))
@@ -322,7 +338,7 @@ ORDER BY
if len(targetDimval1) > 0 { if len(targetDimval1) > 0 {
clustered := make([]ProductImageItem, 0, len(items)) clustered := make([]ProductImageItem, 0, len(items))
for _, it := range items { for _, it := range items {
if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok { if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok && filePrimaryMatchesDim1(it.FileName, dim1Upper) {
clustered = append(clustered, it) clustered = append(clustered, it)
} }
} }