fix(back-end): fix hex color
All checks were successful
Build and Deploy / test-backend (push) Successful in 26s
Build and Deploy / test-frontend (push) Successful in 1m1s
Build and Deploy / build-and-push (push) Successful in 34s
Build and Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-03-11 10:21:15 +01:00
parent e0aaa7c92e
commit 30ada043ef
2 changed files with 22 additions and 16 deletions

View File

@@ -125,6 +125,18 @@ jobs:
docker build -t "$FRONTEND_IMAGE" ./frontend docker build -t "$FRONTEND_IMAGE" ./frontend
docker push "$FRONTEND_IMAGE" docker push "$FRONTEND_IMAGE"
- name: Cleanup Docker on runner (prevent vdisk growth)
if: always()
shell: bash
run: |
set +e
# Keep recent artifacts, drop old local residue from CI builds.
docker container prune -f --filter "until=168h" || true
docker image prune -a -f --filter "until=168h" || true
docker builder prune -a -f --filter "until=168h" || true
docker network prune -f --filter "until=168h" || true
deploy: deploy:
needs: build-and-push needs: build-and-push
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -37,7 +37,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@@ -45,7 +44,6 @@ import java.util.stream.Collectors;
public class PublicShopCatalogService { public class PublicShopCatalogService {
private static final String SHOP_CATEGORY_MEDIA_USAGE_TYPE = "SHOP_CATEGORY"; private static final String SHOP_CATEGORY_MEDIA_USAGE_TYPE = "SHOP_CATEGORY";
private static final String SHOP_PRODUCT_MEDIA_USAGE_TYPE = "SHOP_PRODUCT"; private static final String SHOP_PRODUCT_MEDIA_USAGE_TYPE = "SHOP_PRODUCT";
private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("^#?[A-Fa-f0-9]{6}$");
private final ShopCategoryRepository shopCategoryRepository; private final ShopCategoryRepository shopCategoryRepository;
private final ShopProductRepository shopProductRepository; private final ShopProductRepository shopProductRepository;
@@ -224,11 +222,11 @@ public class PublicShopCatalogService {
continue; continue;
} }
String normalizedHex = normalizeHexColor(variant.getColorHex()); String colorHex = trimToNull(variant.getColorHex());
if (normalizedHex == null) { if (colorHex == null) {
continue; continue;
} }
colorsByMaterialAndColor.putIfAbsent(key, normalizedHex); colorsByMaterialAndColor.putIfAbsent(key, colorHex);
} }
return colorsByMaterialAndColor; return colorsByMaterialAndColor;
} }
@@ -455,7 +453,7 @@ public class PublicShopCatalogService {
if (variant == null) { if (variant == null) {
return null; return null;
} }
String colorHex = normalizeHexColor(variant.getColorHex()); String colorHex = trimToNull(variant.getColorHex());
if (colorHex == null) { if (colorHex == null) {
String key = toMaterialAndColorKey(variant.getInternalMaterialCode(), variant.getColorName()); String key = toMaterialAndColorKey(variant.getInternalMaterialCode(), variant.getColorName());
colorHex = key != null ? variantColorHexByMaterialAndColor.get(key) : null; colorHex = key != null ? variantColorHexByMaterialAndColor.get(key) : null;
@@ -481,31 +479,27 @@ public class PublicShopCatalogService {
} }
private String normalizeMaterialCode(String materialCode) { private String normalizeMaterialCode(String materialCode) {
String raw = String.valueOf(materialCode == null ? "" : materialCode).trim(); String raw = trimToNull(materialCode);
if (raw.isEmpty()) { if (raw == null) {
return null; return null;
} }
return raw.toUpperCase(Locale.ROOT); return raw.toUpperCase(Locale.ROOT);
} }
private String normalizeColorName(String colorName) { private String normalizeColorName(String colorName) {
String raw = String.valueOf(colorName == null ? "" : colorName).trim(); String raw = trimToNull(colorName);
if (raw.isEmpty()) { if (raw == null) {
return null; return null;
} }
return raw.toLowerCase(Locale.ROOT); return raw.toLowerCase(Locale.ROOT);
} }
private String normalizeHexColor(String value) { private String trimToNull(String value) {
String raw = String.valueOf(value == null ? "" : value).trim(); String raw = String.valueOf(value == null ? "" : value).trim();
if (raw.isEmpty()) { if (raw.isEmpty()) {
return null; return null;
} }
if (!HEX_COLOR_PATTERN.matcher(raw).matches()) { return raw;
return null;
}
String withHash = raw.startsWith("#") ? raw : "#" + raw;
return withHash.toUpperCase(Locale.ROOT);
} }
private ShopProductModelDto toProductModelDto(ProductEntry entry) { private ShopProductModelDto toProductModelDto(ProductEntry entry) {