Fix some UI issues 2
This commit is contained in:
@@ -261,4 +261,125 @@ class RecipeService:
|
||||
return {
|
||||
"success": False,
|
||||
"error": str(e)
|
||||
}
|
||||
}
|
||||
|
||||
# Quality Configuration Methods
|
||||
|
||||
async def update_recipe_quality_configuration(
|
||||
self,
|
||||
tenant_id: UUID,
|
||||
recipe_id: UUID,
|
||||
quality_config_update: Dict[str, Any],
|
||||
user_id: UUID
|
||||
) -> Dict[str, Any]:
|
||||
"""Update quality configuration for a recipe"""
|
||||
try:
|
||||
# Get current recipe
|
||||
recipe = await self.recipe_repo.get_recipe(tenant_id, recipe_id)
|
||||
if not recipe:
|
||||
raise ValueError("Recipe not found")
|
||||
|
||||
# Get existing quality configuration or create default
|
||||
current_config = recipe.get("quality_check_configuration", {
|
||||
"stages": {},
|
||||
"overall_quality_threshold": 7.0,
|
||||
"critical_stage_blocking": True,
|
||||
"auto_create_quality_checks": True,
|
||||
"quality_manager_approval_required": False
|
||||
})
|
||||
|
||||
# Merge with updates
|
||||
if "stages" in quality_config_update:
|
||||
current_config["stages"].update(quality_config_update["stages"])
|
||||
|
||||
for key in ["overall_quality_threshold", "critical_stage_blocking",
|
||||
"auto_create_quality_checks", "quality_manager_approval_required"]:
|
||||
if key in quality_config_update:
|
||||
current_config[key] = quality_config_update[key]
|
||||
|
||||
# Update recipe with new configuration
|
||||
recipe_update = RecipeUpdate(quality_check_configuration=current_config)
|
||||
await self.recipe_repo.update_recipe(tenant_id, recipe_id, recipe_update, user_id)
|
||||
|
||||
# Return updated recipe
|
||||
updated_recipe = await self.recipe_repo.get_recipe(tenant_id, recipe_id)
|
||||
return updated_recipe
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error updating recipe quality configuration: {e}")
|
||||
raise
|
||||
|
||||
async def add_quality_templates_to_stage(
|
||||
self,
|
||||
tenant_id: UUID,
|
||||
recipe_id: UUID,
|
||||
stage: str,
|
||||
template_ids: List[UUID],
|
||||
user_id: UUID
|
||||
):
|
||||
"""Add quality templates to a specific recipe stage"""
|
||||
try:
|
||||
# Get current recipe
|
||||
recipe = await self.recipe_repo.get_recipe(tenant_id, recipe_id)
|
||||
if not recipe:
|
||||
raise ValueError("Recipe not found")
|
||||
|
||||
# Get existing quality configuration
|
||||
quality_config = recipe.get("quality_check_configuration", {"stages": {}})
|
||||
|
||||
# Initialize stage if it doesn't exist
|
||||
if stage not in quality_config["stages"]:
|
||||
quality_config["stages"][stage] = {
|
||||
"template_ids": [],
|
||||
"required_checks": [],
|
||||
"optional_checks": [],
|
||||
"blocking_on_failure": True,
|
||||
"min_quality_score": None
|
||||
}
|
||||
|
||||
# Add template IDs (avoid duplicates)
|
||||
stage_config = quality_config["stages"][stage]
|
||||
existing_ids = set(stage_config.get("template_ids", []))
|
||||
new_ids = [str(tid) for tid in template_ids if str(tid) not in existing_ids]
|
||||
stage_config["template_ids"].extend(new_ids)
|
||||
|
||||
# Update recipe
|
||||
recipe_update = RecipeUpdate(quality_check_configuration=quality_config)
|
||||
await self.recipe_repo.update_recipe(tenant_id, recipe_id, recipe_update, user_id)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error adding quality templates to stage: {e}")
|
||||
raise
|
||||
|
||||
async def remove_quality_template_from_stage(
|
||||
self,
|
||||
tenant_id: UUID,
|
||||
recipe_id: UUID,
|
||||
stage: str,
|
||||
template_id: UUID,
|
||||
user_id: UUID
|
||||
):
|
||||
"""Remove a quality template from a specific recipe stage"""
|
||||
try:
|
||||
# Get current recipe
|
||||
recipe = await self.recipe_repo.get_recipe(tenant_id, recipe_id)
|
||||
if not recipe:
|
||||
raise ValueError("Recipe not found")
|
||||
|
||||
# Get existing quality configuration
|
||||
quality_config = recipe.get("quality_check_configuration", {"stages": {}})
|
||||
|
||||
# Remove template ID from stage
|
||||
if stage in quality_config["stages"]:
|
||||
stage_config = quality_config["stages"][stage]
|
||||
template_ids = stage_config.get("template_ids", [])
|
||||
template_ids = [tid for tid in template_ids if str(tid) != str(template_id)]
|
||||
stage_config["template_ids"] = template_ids
|
||||
|
||||
# Update recipe
|
||||
recipe_update = RecipeUpdate(quality_check_configuration=quality_config)
|
||||
await self.recipe_repo.update_recipe(tenant_id, recipe_id, recipe_update, user_id)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error removing quality template from stage: {e}")
|
||||
raise
|
||||
Reference in New Issue
Block a user