v9d Phase 2d: Vitals Module Refactoring (Baseline + Blood Pressure) #22
|
|
@ -16,7 +16,15 @@ from auth import require_auth, check_feature_access, increment_feature_usage
|
|||
from models import ActivityEntry
|
||||
from routers.profiles import get_pid
|
||||
from feature_logger import log_feature_usage
|
||||
|
||||
# Evaluation import with error handling (Phase 1.2)
|
||||
try:
|
||||
from evaluation_helper import evaluate_and_save_activity
|
||||
EVALUATION_AVAILABLE = True
|
||||
except Exception as e:
|
||||
logger.warning(f"[AUTO-EVAL] Evaluation system not available: {e}")
|
||||
EVALUATION_AVAILABLE = False
|
||||
evaluate_and_save_activity = None
|
||||
|
||||
router = APIRouter(prefix="/api/activity", tags=["activity"])
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -66,6 +74,7 @@ def create_activity(e: ActivityEntry, x_profile_id: Optional[str]=Header(default
|
|||
d['rpe'],d['source'],d['notes']))
|
||||
|
||||
# Phase 1.2: Auto-evaluation after INSERT
|
||||
if EVALUATION_AVAILABLE:
|
||||
# Load the activity data to evaluate
|
||||
cur.execute("""
|
||||
SELECT id, profile_id, date, training_type_id, duration_min,
|
||||
|
|
@ -102,6 +111,7 @@ def update_activity(eid: str, e: ActivityEntry, x_profile_id: Optional[str]=Head
|
|||
list(d.values())+[eid,pid])
|
||||
|
||||
# Phase 1.2: Auto-evaluation after UPDATE
|
||||
if EVALUATION_AVAILABLE:
|
||||
# Load the updated activity data to evaluate
|
||||
cur.execute("""
|
||||
SELECT id, profile_id, date, training_type_id, duration_min,
|
||||
|
|
@ -257,6 +267,7 @@ def bulk_categorize_activities(
|
|||
updated_count = cur.rowcount
|
||||
|
||||
# Phase 1.2: Auto-evaluation after bulk categorization
|
||||
if EVALUATION_AVAILABLE:
|
||||
# Load all activities that were just updated and evaluate them
|
||||
cur.execute("""
|
||||
SELECT id, profile_id, date, training_type_id, duration_min,
|
||||
|
|
@ -369,7 +380,7 @@ async def import_activity_csv(file: UploadFile=File(...), x_profile_id: Optional
|
|||
skipped += 1 # Count as skipped (not newly inserted)
|
||||
|
||||
# Phase 1.2: Auto-evaluation after CSV import UPDATE
|
||||
if training_type_id:
|
||||
if EVALUATION_AVAILABLE and training_type_id:
|
||||
try:
|
||||
# Build activity dict for evaluation
|
||||
activity_dict = {
|
||||
|
|
@ -408,7 +419,7 @@ async def import_activity_csv(file: UploadFile=File(...), x_profile_id: Optional
|
|||
inserted+=1
|
||||
|
||||
# Phase 1.2: Auto-evaluation after CSV import INSERT
|
||||
if training_type_id:
|
||||
if EVALUATION_AVAILABLE and training_type_id:
|
||||
try:
|
||||
# Build activity dict for evaluation
|
||||
activity_dict = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user