refactor: Update load_scanner_reports with debug logging and robust path resolution
This commit is contained in:
parent
f4f7505e5c
commit
5502c54845
@ -13,22 +13,31 @@ def load_scanner_reports(scanner_type: str = None):
|
|||||||
list: List of dictionaries containing report information
|
list: List of dictionaries containing report information
|
||||||
"""
|
"""
|
||||||
reports = []
|
reports = []
|
||||||
reports_dir = Path("src/reports")
|
|
||||||
|
# Get absolute path to reports directory
|
||||||
|
reports_dir = Path.cwd() / "reports"
|
||||||
|
|
||||||
# Create reports directory if it doesn't exist
|
# Create reports directory if it doesn't exist
|
||||||
reports_dir.mkdir(parents=True, exist_ok=True)
|
reports_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
if reports_dir.exists():
|
if reports_dir.exists():
|
||||||
|
# Print debug info
|
||||||
|
print(f"Scanning directory: {reports_dir}")
|
||||||
|
|
||||||
for file in reports_dir.glob("*.csv"):
|
for file in reports_dir.glob("*.csv"):
|
||||||
|
print(f"Found file: {file.name}") # Debug print
|
||||||
|
|
||||||
# Get file creation time
|
# Get file creation time
|
||||||
created = datetime.fromtimestamp(file.stat().st_ctime)
|
created = datetime.fromtimestamp(file.stat().st_ctime)
|
||||||
|
|
||||||
# If scanner_type is specified, filter based on actual naming patterns
|
# If scanner_type is specified, filter based on actual naming patterns
|
||||||
if scanner_type == "technical":
|
if scanner_type == "technical":
|
||||||
if not (file.name.startswith(("atr_ema_", "sunny_"))):
|
if not (file.name.startswith(("atr_ema_", "sunny_"))):
|
||||||
|
print(f"Skipping {file.name} - not a technical report") # Debug print
|
||||||
continue
|
continue
|
||||||
elif scanner_type == "canslim":
|
elif scanner_type == "canslim":
|
||||||
if not file.name.startswith("canslim_"):
|
if not file.name.startswith("canslim_"):
|
||||||
|
print(f"Skipping {file.name} - not a CANSLIM report") # Debug print
|
||||||
continue
|
continue
|
||||||
|
|
||||||
reports.append({
|
reports.append({
|
||||||
@ -36,6 +45,10 @@ def load_scanner_reports(scanner_type: str = None):
|
|||||||
'path': str(file),
|
'path': str(file),
|
||||||
'created': created
|
'created': created
|
||||||
})
|
})
|
||||||
|
print(f"Added report: {file.name}") # Debug print
|
||||||
|
|
||||||
|
# Print final count
|
||||||
|
print(f"Found {len(reports)} matching reports")
|
||||||
|
|
||||||
# Sort by creation time, newest first
|
# Sort by creation time, newest first
|
||||||
return sorted(reports, key=lambda x: x['created'], reverse=True)
|
return sorted(reports, key=lambda x: x['created'], reverse=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user