mitai-jinkendo/backend/test_export.py
Lars 61a5bb39ae
All checks were successful
Deploy Development / deploy (push) Successful in 59s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s
feat: Update nutrition metrics and energy balance calculations
- Introduced a single TDEE calculation based on current weight, replacing the fixed 2500 kcal value.
- Updated `get_energy_balance_data` to use daily totals for intake calculations and improved energy balance logic.
- Enhanced `get_nutrition_average_data` to calculate averages over calendar days instead of raw log entries.
- Adjusted placeholder resolution to ensure consistent metadata usage across requests.
- Fixed issues in the charts router to reflect the new energy balance logic and TDEE calculations.

These changes improve the accuracy of nutritional assessments and streamline data handling in the application.
2026-04-11 19:04:27 +02:00

66 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Test export-all endpoint"""
import sys
sys.path.insert(0, '/app')
from datetime import datetime
from db import get_db, get_cursor, r2d
print("Testing export-all logic...")
with get_db() as conn:
cur = get_cursor(conn)
cur.execute("SELECT * FROM ai_prompts ORDER BY sort_order, slug")
prompts = [r2d(row) for row in cur.fetchall()]
print(f"Found {len(prompts)} prompts")
# Convert to export format (clean up DB-specific fields)
export_data = []
for idx, p in enumerate(prompts):
print(f"\nProcessing prompt {idx+1}: {p.get('slug')}")
try:
export_item = {
'slug': p['slug'],
'name': p['name'],
'display_name': p.get('display_name'),
'description': p.get('description'),
'type': p.get('type', 'pipeline'),
'category': p.get('category', 'ganzheitlich'),
'template': p.get('template'),
'stages': p.get('stages'),
'output_format': p.get('output_format', 'text'),
'output_schema': p.get('output_schema'),
'question_augmentations': p.get('question_augmentations'),
'graph_data': p.get('graph_data'),
'active': p.get('active', True),
'sort_order': p.get('sort_order', 0)
}
export_data.append(export_item)
print(f" ✓ OK")
except Exception as e:
print(f" ✗ ERROR: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()
break
print(f"\n\nSuccessfully processed {len(export_data)} prompts")
# Try to create the response dict
try:
result = {
'export_date': datetime.now().isoformat(),
'count': len(export_data),
'prompts': export_data
}
print("✓ Result dict created successfully")
# Try JSON serialization
import json
json_str = json.dumps(result)
print(f"✓ JSON serialization OK, length: {len(json_str)}")
except Exception as e:
print(f"✗ ERROR creating result: {type(e).__name__}: {e}")
import traceback
traceback.print_exc()