teljes backend_mentés
This commit is contained in:
129
classify_workers.py
Normal file
129
classify_workers.py
Normal file
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
|
||||
# List of files from audit ledger (relative to backend/app/)
|
||||
files = [
|
||||
"workers/monitor_dashboard.py",
|
||||
"workers/monitor_dashboard2.0.py",
|
||||
"workers/ocr/robot_1_ocr_processor.py",
|
||||
"workers/py_to_database.py",
|
||||
"workers/service/service_robot_0_hunter.py",
|
||||
"workers/service/service_robot_1_scout_osm.py",
|
||||
"workers/service/service_robot_2_researcher.py",
|
||||
"workers/service/service_robot_3_enricher.py",
|
||||
"workers/service/service_robot_4_validator_google.py",
|
||||
"workers/service/service_robot_5_auditor.py",
|
||||
"workers/system/subscription_worker.py",
|
||||
"workers/system/system_robot_2_service_auditor.py",
|
||||
"workers/vehicle/R0_brand_hunter.py",
|
||||
"workers/vehicle/R1_model_scout.py",
|
||||
"workers/vehicle/R2_generation_scout.py",
|
||||
"workers/vehicle/R3_engine_scout.py",
|
||||
"workers/vehicle/R4_final_extractor.py",
|
||||
"workers/vehicle/bike/bike_R0_brand_hunter.py",
|
||||
"workers/vehicle/bike/bike_R1_model_scout.py",
|
||||
"workers/vehicle/bike/bike_R2_generation_scout.py",
|
||||
"workers/vehicle/bike/bike_R3_engine_scout.py",
|
||||
"workers/vehicle/bike/bike_R4_final_extractor.py",
|
||||
"workers/vehicle/bike/test_aprilia.py",
|
||||
"workers/vehicle/mapping_dictionary.py",
|
||||
"workers/vehicle/mapping_rules.py",
|
||||
"workers/vehicle/r5_test.py",
|
||||
"workers/vehicle/r5_ultimate_harvester.py",
|
||||
"workers/vehicle/robot_report.py",
|
||||
"workers/vehicle/ultimatespecs/vehicle_ultimate_r0_spider.py",
|
||||
"workers/vehicle/ultimatespecs/vehicle_ultimate_r1_scraper.py",
|
||||
"workers/vehicle/ultimatespecs/vehicle_ultimate_r2_enricher.py",
|
||||
"workers/vehicle/ultimatespecs/vehicle_ultimate_r3_finalizer.py",
|
||||
"workers/vehicle/vehicle_data_loader.py",
|
||||
"workers/vehicle/vehicle_robot_0_discovery_engine.py",
|
||||
"workers/vehicle/vehicle_robot_0_gb_discovery.py",
|
||||
"workers/vehicle/vehicle_robot_1_2_nhtsa_fetcher.py",
|
||||
"workers/vehicle/vehicle_robot_1_4_bike_hunter.py",
|
||||
"workers/vehicle/vehicle_robot_1_5_heavy_eu.py",
|
||||
"workers/vehicle/vehicle_robot_1_5_heavy_eu1.0.py",
|
||||
"workers/vehicle/vehicle_robot_1_catalog_hunter.py",
|
||||
"workers/vehicle/vehicle_robot_1_gb_hunter.py",
|
||||
"workers/vehicle/vehicle_robot_2_1_rdw_enricher.py",
|
||||
"workers/vehicle/vehicle_robot_2_1_ultima_scout.py",
|
||||
"workers/vehicle/vehicle_robot_2_1_ultima_scout_1.0.py",
|
||||
"workers/vehicle/vehicle_robot_2_auto_data_net.py",
|
||||
"workers/vehicle/vehicle_robot_2_researcher.py",
|
||||
"workers/vehicle/vehicle_robot_3_alchemist_pro.py",
|
||||
"workers/vehicle/vehicle_robot_4_validator.py",
|
||||
"workers/vehicle/vehicle_robot_4_vin_auditor.py"
|
||||
]
|
||||
|
||||
def check_ghost(filepath):
|
||||
try:
|
||||
with open(os.path.join("backend/app", filepath), 'r') as f:
|
||||
content = f.read()
|
||||
return "'ghost'" in content or '"ghost"' in content
|
||||
except:
|
||||
return False
|
||||
|
||||
def check_beautifulsoup(filepath):
|
||||
try:
|
||||
with open(os.path.join("backend/app", filepath), 'r') as f:
|
||||
content = f.read()
|
||||
return "BeautifulSoup" in content or "from bs4" in content
|
||||
except:
|
||||
return False
|
||||
|
||||
def is_duplicate(filepath):
|
||||
# detect 1.0 duplicates
|
||||
if filepath.endswith("1.0.py"):
|
||||
# check if non-1.0 exists
|
||||
base = filepath[:-6] + ".py"
|
||||
if base in files:
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_test(filepath):
|
||||
return "test" in filepath.lower() and not ("robot" in filepath or "vehicle" in filepath)
|
||||
|
||||
def is_small(filepath):
|
||||
try:
|
||||
lines = sum(1 for _ in open(os.path.join("backend/app", filepath), 'r'))
|
||||
return lines < 30
|
||||
except:
|
||||
return False
|
||||
|
||||
# classify
|
||||
tags = {}
|
||||
for f in files:
|
||||
if check_ghost(f):
|
||||
tags[f] = ("[REFAKTORÁL]", "Contains hardcoded 'ghost' status; should use ServiceStatus Enum.")
|
||||
elif check_beautifulsoup(f):
|
||||
tags[f] = ("[REFAKTORÁL]", "Uses BeautifulSoup for web scraping; consider modernizing to async HTTP client and structured data extraction.")
|
||||
elif is_duplicate(f):
|
||||
tags[f] = ("[TÖRÖLHETŐ]", "Duplicate of non-1.0 version; remove to avoid confusion.")
|
||||
elif is_test(f):
|
||||
tags[f] = ("[TÖRÖLHETŐ]", "Test file; not needed in production.")
|
||||
elif is_small(f):
|
||||
tags[f] = ("[TÖRÖLHETŐ]", "Small utility likely unused.")
|
||||
else:
|
||||
tags[f] = ("[MEGTART]", "Modern code, part of active robot pipeline.")
|
||||
|
||||
# output new lines
|
||||
for f in files:
|
||||
tag, reason = tags[f]
|
||||
print(f"- [ ] `{f}` - {tag} {reason}")
|
||||
|
||||
# statistics
|
||||
counts = {"MEGTART":0, "REFAKTORÁL":0, "TÖRÖLHETŐ":0}
|
||||
for tag, _ in tags.values():
|
||||
if tag == "[MEGTART]":
|
||||
counts["MEGTART"] += 1
|
||||
elif tag == "[REFAKTORÁL]":
|
||||
counts["REFAKTORÁL"] += 1
|
||||
elif tag == "[TÖRÖLHETŐ]":
|
||||
counts["TÖRÖLHETŐ"] += 1
|
||||
|
||||
print("\nStatistics:")
|
||||
print(f"MEGTART: {counts['MEGTART']}")
|
||||
print(f"REFAKTORÁL: {counts['REFAKTORÁL']}")
|
||||
print(f"TÖRÖLHETŐ: {counts['TÖRÖLHETŐ']}")
|
||||
print(f"Total: {sum(counts.values())}")
|
||||
Reference in New Issue
Block a user