many updates
This commit is contained in:
50
FitnessSync/backend/debug_estimated_power.py
Normal file
50
FitnessSync/backend/debug_estimated_power.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from src.services.postgresql_manager import PostgreSQLManager
|
||||
from src.utils.config import config
|
||||
from src.models.activity import Activity
|
||||
from src.services.power_estimator import PowerEstimatorService
|
||||
from sqlalchemy import text, or_
|
||||
|
||||
def debug_power():
|
||||
print("Debugging Estimated Power...")
|
||||
db_manager = PostgreSQLManager(config.DATABASE_URL)
|
||||
with db_manager.get_db_session() as session:
|
||||
# 1. Total Cycling
|
||||
cycling_count = session.query(Activity).filter(Activity.activity_type.ilike('%cycling%')).count()
|
||||
print(f"Total Cycling Activities: {cycling_count}")
|
||||
|
||||
# 2. Missing Power
|
||||
missing_power = session.query(Activity).filter(
|
||||
Activity.activity_type.ilike('%cycling%'),
|
||||
(Activity.avg_power == None) | (Activity.avg_power == 0)
|
||||
).count()
|
||||
print(f"Cycling with Missing Power: {missing_power}")
|
||||
|
||||
# 3. Already Estimated
|
||||
estimated_count = session.query(Activity).filter(Activity.is_estimated_power == True).count()
|
||||
print(f"Activities with is_estimated_power=True: {estimated_count}")
|
||||
|
||||
# 4. Candidates for Job
|
||||
candidates = session.query(Activity).filter(
|
||||
Activity.activity_type.ilike('%cycling%'),
|
||||
(Activity.avg_power == None) | (Activity.avg_power == 0),
|
||||
Activity.file_content != None
|
||||
).all()
|
||||
print(f"Job Candidates (Cycling + No Power + Has File): {len(candidates)}")
|
||||
|
||||
if len(candidates) > 0:
|
||||
print(f"First candidate ID: {candidates[0].id}")
|
||||
# Try to estimate one
|
||||
print("Attempting to estimate power for first candidate...")
|
||||
try:
|
||||
estimator = PowerEstimatorService(session)
|
||||
res = estimator.estimate_power_for_activity(candidates[0].id)
|
||||
print(f"Test Estimation Result: {res}")
|
||||
except Exception as e:
|
||||
print(f"Test Estimation FAILED: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
else:
|
||||
print("No candidates found for estimation.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug_power()
|
||||
Reference in New Issue
Block a user