debug: Add detailed logging to approval flow (v1.3.82)
- Add logging before approval object creation - Add logging after approval object creation - Add logging before database update - Add logging after database update - Add time_id to error messages - This will help diagnose 500 errors on production
This commit is contained in:
parent
420507027a
commit
45d4f78006
@ -287,6 +287,8 @@ async def approve_time_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Godkend med alle felter
|
# Godkend med alle felter
|
||||||
|
logger.info(f"🔍 Creating approval for time_id={time_id}: approved_hours={approved_hours}, rounded_to={rounded_to}, is_travel={request.get('is_travel', False)}")
|
||||||
|
|
||||||
approval = TModuleTimeApproval(
|
approval = TModuleTimeApproval(
|
||||||
time_id=time_id,
|
time_id=time_id,
|
||||||
approved_hours=approved_hours,
|
approved_hours=approved_hours,
|
||||||
@ -296,11 +298,12 @@ async def approve_time_entry(
|
|||||||
is_travel=request.get('is_travel', False)
|
is_travel=request.get('is_travel', False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.info(f"✅ Approval object created successfully")
|
||||||
return wizard.approve_time_entry(approval, user_id=user_id)
|
return wizard.approve_time_entry(approval, user_id=user_id)
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"❌ Error approving entry: {e}", exc_info=True)
|
logger.error(f"❌ Error approving entry {time_id}: {e}", exc_info=True)
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -173,6 +173,7 @@ class WizardService:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Update entry
|
# Update entry
|
||||||
|
logger.info(f"🔄 Updating time entry {approval.time_id} in database")
|
||||||
update_query = """
|
update_query = """
|
||||||
UPDATE tmodule_times
|
UPDATE tmodule_times
|
||||||
SET status = 'approved',
|
SET status = 'approved',
|
||||||
@ -199,6 +200,8 @@ class WizardService:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.info(f"✅ Database update successful for time entry {approval.time_id}")
|
||||||
|
|
||||||
# Log approval
|
# Log approval
|
||||||
audit.log_approval(
|
audit.log_approval(
|
||||||
time_id=approval.time_id,
|
time_id=approval.time_id,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user