Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-07-05 05:16:31 +03:00
parent 48bde09c2c
commit 27934bccdf
5 changed files with 486 additions and 162 deletions
+16 -7
View File
@@ -141,18 +141,14 @@ func enrichProductImageItem(it *ProductImageItem) {
if it == nil {
return
}
if it.ID > 0 {
it.ContentURL = fmt.Sprintf("/api/product-images/%d/content", it.ID)
}
if u := extractImageUUID(it.Storage, it.FileName); u != "" {
it.UUID = u
it.ThumbURL = "/uploads/image/t300/" + u + ".jpg"
it.FullURL = "/uploads/image/" + u + ".jpg"
}
if it.StoredInDB {
it.ContentURL = fmt.Sprintf("/api/product-images/%d/content", it.ID)
return
}
if resolved, _ := resolveStoragePath(it.Storage); resolved != "" {
it.ContentURL = fmt.Sprintf("/api/product-images/%d/content", it.ID)
}
}
// POST /api/product-images/batch
@@ -576,14 +572,25 @@ func resolveStoragePath(storagePath string) (string, []string) {
raw = filepath.ToSlash(filepath.Clean(raw))
relUploads := filepath.FromSlash(filepath.Join("uploads", raw))
baseName := filepath.Base(raw)
relImage := filepath.FromSlash(filepath.Join("uploads", "image", baseName))
relImageThumb := filepath.FromSlash(filepath.Join("uploads", "image", "t300", baseName))
candidates := []string{
filepath.Clean(storagePath),
filepath.FromSlash(filepath.Clean(strings.TrimPrefix(storagePath, "/"))),
filepath.FromSlash(filepath.Clean(raw)),
relUploads,
relImage,
relImageThumb,
filepath.Join(".", relUploads),
filepath.Join(".", relImage),
filepath.Join(".", relImageThumb),
filepath.Join("..", relUploads),
filepath.Join("..", relImage),
filepath.Join("..", relImageThumb),
filepath.Join("..", "..", relUploads),
filepath.Join("..", "..", relImage),
filepath.Join("..", "..", relImageThumb),
}
if root := strings.TrimSpace(os.Getenv("BLOB_ROOT")); root != "" {
@@ -591,6 +598,8 @@ func resolveStoragePath(storagePath string) (string, []string) {
filepath.Join(root, raw),
filepath.Join(root, relUploads),
filepath.Join(root, "uploads", raw),
filepath.Join(root, relImage),
filepath.Join(root, relImageThumb),
)
}