fix
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/processing"
|
||||
)
|
||||
|
||||
func main() {
|
||||
badItems := []processing.V1ProcessJobItem{
|
||||
{
|
||||
"ean": "8806091734365",
|
||||
"status": "processed",
|
||||
"title": "LG Ameriški hladilnikGSXV80PZLE",
|
||||
"name": "LG Ameriški hladilnikGSXV80PZLE",
|
||||
"category": "11",
|
||||
"category_name": "Hladilniki",
|
||||
"description": "<h1>LG Ameriški hladilnikGSXV80PZLE</h1><p>LG Ameriški hladilnikGSXV80PZLE je izdelek v kategoriji Hladilniki znamke LG. Ključne specifikacije: width 179, height 91.3, depth 73.5.</p><h2>Ključne lastnosti</h2><ul><li>width 179</li><li>height 91.3</li><li>depth 73.5</li></ul><p>LG Ameriški hladilnikGSXV80PZLE je izdelek v kategoriji Hladilniki znamke LG. Ključne specifikacije: width 179, height 91.3, depth 73.5.</p><p>LG Ameriški hladilnikGSXV80PZLE je izdelek v kategoriji Hladilniki znamke LG. Ključne specifikacije: width 179, height 91.3, depth 73.5.</p><p>LG Ameriški hladilnikGSXV80PZLE je izdelek v kategoriji Hladilniki znamke LG. Ključne specifikacije: width 179, height 91.3, depth 73.5.</p>",
|
||||
"attributes": map[string]any{"brand": "LG", "depth": "73.5", "energy_class": "E", "height": "91.3", "warranty": "24 mesecev", "width": "179"},
|
||||
"meta_title": "LG Ameriški hladilnikGSXV80PZLE | Hladilniki",
|
||||
"meta_description": "x",
|
||||
"eprel": map[string]any{"id": "1158009", "energy_class": "E"},
|
||||
"id": "1bc20e89-3779-4c66-8617-8e72555cd363",
|
||||
"processed_product_id": "1bc20e89-3779-4c66-8617-8e72555cd363",
|
||||
"raw_product_id": "fff13ee3-e78c-4185-b524-b64128bbc38b",
|
||||
"main_image": "https://example/lg.jpg",
|
||||
"more_images": nil,
|
||||
},
|
||||
{
|
||||
"ean": "8422160053580",
|
||||
"status": "processed",
|
||||
"title": "Ufesa digitalni zračni cvrtnik 23L Magnum",
|
||||
"name": "Ufesa digitalni zračni cvrtnik 23L Magnum",
|
||||
"category": "112",
|
||||
"category_name": "Ostali aparati",
|
||||
"description": "<h1>Ufesa digitalni zračni cvrtnik 23L Magnum</h1><p>Ufesa digitalni zračni cvrtnik 23L Magnum je izdelek v kategoriji Ostali aparati znamke UFESA. Ključne specifikacije: width 0,00m, height 0,00m, depth 0,00m.</p><h2>Ključne lastnosti</h2><ul><li>width 0,00m</li><li>height 0,00m</li><li>depth 0,00m</li><li>weight 11,0000kg</li></ul><p>Ufesa digitalni zračni cvrtnik 23L Magnum je izdelek v kategoriji Ostali aparati znamke UFESA. Ključne specifikacije: width 0,00m, height 0,00m, depth 0,00m.</p>",
|
||||
"attributes": map[string]any{"brand": "UFESA", "depth": "0,00m", "height": "0,00m", "warranty": "24 mesecev", "weight": "11,0000kg", "width": "0,00m"},
|
||||
"meta_title": "x",
|
||||
"meta_description": "y",
|
||||
"eprel": nil,
|
||||
"id": "c708b505-dbf0-40c5-ba09-022d15daff97",
|
||||
"processed_product_id": "c708b505-dbf0-40c5-ba09-022d15daff97",
|
||||
"raw_product_id": "fff6c685-931b-4fa5-846b-89b2503a5a77",
|
||||
"main_image": "https://example/ufesa.jpg",
|
||||
"more_images": []string{"https://example/2.jpg"},
|
||||
},
|
||||
}
|
||||
cleaned := make([]processing.V1ProcessJobItem, 0, len(badItems))
|
||||
for _, it := range badItems {
|
||||
cleaned = append(cleaned, processing.EnforceV1ProcessCompletedItemOpts(it, processing.EnforceV1Opts{
|
||||
Language: "sl",
|
||||
Allowed: map[string]struct{}{},
|
||||
OmitSEOMeta: true,
|
||||
}))
|
||||
}
|
||||
out := map[string]any{
|
||||
"data": map[string]any{
|
||||
"process_id": "13b97eab-2329-4735-82fa-3afe263849fa",
|
||||
"status": "COMPLETED",
|
||||
"processing_type": "full",
|
||||
"total_items": len(cleaned),
|
||||
"items": cleaned,
|
||||
"note": "projection cleanup of production sample (A1 OmitSEOMeta)",
|
||||
},
|
||||
}
|
||||
b, err := json.MarshalIndent(out, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
path := filepath.Join("..", "..", ".codehelper", "_a1_v1_response_20260817", "production_sample_cleaned.json")
|
||||
if err := os.WriteFile(path, b, 0o644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("wrote", path)
|
||||
for _, it := range cleaned {
|
||||
fmt.Printf("ean=%v\ntitle=%v\ncategory=%v category_id=%v\nmeta_present=%v/%v\nattrs=%v\ndesc=%v\n\n",
|
||||
it["ean"], it["title"], it["category"], it["category_id"],
|
||||
it["meta_title"] != nil, it["meta_description"] != nil,
|
||||
it["attributes"], it["description"])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user