Add base kubernetes support final fix 4
This commit is contained in:
@@ -131,15 +131,28 @@ class OnboardingService:
|
||||
|
||||
# Update the step
|
||||
await self._update_user_onboarding_data(
|
||||
user_id,
|
||||
step_name,
|
||||
user_id,
|
||||
step_name,
|
||||
{
|
||||
"completed": update_request.completed,
|
||||
"completed_at": datetime.now(timezone.utc).isoformat() if update_request.completed else None,
|
||||
"data": update_request.data or {}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
# Try to update summary and handle partial failures gracefully
|
||||
try:
|
||||
# Update the user's onboarding summary
|
||||
await self._update_user_summary(user_id)
|
||||
except HTTPException as he:
|
||||
# If it's a 207 Multi-Status (partial success), log warning but continue
|
||||
if he.status_code == status.HTTP_207_MULTI_STATUS:
|
||||
logger.warning(f"Summary update failed for user {user_id}, step {step_name}: {he.detail}")
|
||||
# Continue execution - the step update was successful
|
||||
else:
|
||||
# Re-raise other HTTP exceptions
|
||||
raise
|
||||
|
||||
# Return updated progress
|
||||
return await self.get_user_progress(user_id)
|
||||
|
||||
@@ -284,10 +297,7 @@ class OnboardingService:
|
||||
completed=completed,
|
||||
step_data=data_payload
|
||||
)
|
||||
|
||||
# Update the user's onboarding summary
|
||||
await self._update_user_summary(user_id)
|
||||
|
||||
|
||||
logger.info(f"Successfully updated onboarding step for user {user_id}: {step_name} = {step_data}")
|
||||
return updated_step
|
||||
|
||||
@@ -300,26 +310,26 @@ class OnboardingService:
|
||||
try:
|
||||
# Get updated progress
|
||||
user_progress_data = await self._get_user_onboarding_data(user_id)
|
||||
|
||||
|
||||
# Calculate current status
|
||||
completed_steps = []
|
||||
for step_name in ONBOARDING_STEPS:
|
||||
if user_progress_data.get(step_name, {}).get("completed", False):
|
||||
completed_steps.append(step_name)
|
||||
|
||||
|
||||
# Determine current and next step
|
||||
current_step = self._get_current_step(completed_steps)
|
||||
next_step = self._get_next_step(completed_steps)
|
||||
|
||||
|
||||
# Calculate completion percentage
|
||||
completion_percentage = (len(completed_steps) / len(ONBOARDING_STEPS)) * 100
|
||||
|
||||
|
||||
# Check if fully completed
|
||||
fully_completed = len(completed_steps) == len(ONBOARDING_STEPS)
|
||||
|
||||
|
||||
# Format steps count
|
||||
steps_completed_count = f"{len(completed_steps)}/{len(ONBOARDING_STEPS)}"
|
||||
|
||||
|
||||
# Update summary in database
|
||||
await self.onboarding_repo.upsert_user_summary(
|
||||
user_id=user_id,
|
||||
@@ -329,10 +339,18 @@ class OnboardingService:
|
||||
fully_completed=fully_completed,
|
||||
steps_completed_count=steps_completed_count
|
||||
)
|
||||
|
||||
|
||||
logger.debug(f"Successfully updated onboarding summary for user {user_id}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating onboarding summary for user {user_id}: {e}")
|
||||
# Don't raise here - summary update failure shouldn't break step updates
|
||||
logger.error(f"Error updating onboarding summary for user {user_id}: {e}",
|
||||
extra={"user_id": user_id, "error_type": type(e).__name__})
|
||||
# Raise a warning-level HTTPException to inform frontend without breaking the flow
|
||||
# This allows the step update to succeed while alerting about summary issues
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_207_MULTI_STATUS,
|
||||
detail=f"Step updated successfully, but summary update failed: {str(e)}"
|
||||
)
|
||||
|
||||
# API Routes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user