Fix: Deduplicate packages based on full JSON content hash to prevent double counting
This commit is contained in:
@@ -564,9 +564,22 @@ def fetch_all_packages():
|
|||||||
|
|
||||||
def process_packages_breakdown(packages):
|
def process_packages_breakdown(packages):
|
||||||
model_counts = {}
|
model_counts = {}
|
||||||
|
seen_package_hashes = set()
|
||||||
|
|
||||||
print(f"\n--- Raw Package Processing ---", flush=True)
|
print(f"\n--- Raw Package Processing ---", flush=True)
|
||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
try:
|
try:
|
||||||
|
# 0. Deduplication (Exact Match)
|
||||||
|
# VolcEngine pagination bugs might return duplicate items or pages.
|
||||||
|
# We assume identical JSON objects are duplicates.
|
||||||
|
pkg_hash = hashlib.md5(json.dumps(pkg, sort_keys=True).encode()).hexdigest()
|
||||||
|
if pkg_hash in seen_package_hashes:
|
||||||
|
if DEBUG_MODE:
|
||||||
|
print(f"DEBUG: Skipping duplicate package (Hash: {pkg_hash})")
|
||||||
|
continue
|
||||||
|
seen_package_hashes.add(pkg_hash)
|
||||||
|
|
||||||
raw_code = pkg.get("ConfigurationCode", "")
|
raw_code = pkg.get("ConfigurationCode", "")
|
||||||
raw_name = pkg.get("ConfigurationName", "Unknown")
|
raw_name = pkg.get("ConfigurationName", "Unknown")
|
||||||
target_raw = raw_code if raw_code else raw_name
|
target_raw = raw_code if raw_code else raw_name
|
||||||
|
|||||||
Reference in New Issue
Block a user