Improve the demo feature of the project
This commit is contained in:
@@ -12,7 +12,7 @@ from datetime import datetime
|
||||
import structlog
|
||||
|
||||
from shared.database.repository import BaseRepository
|
||||
from ..models.recipes import Recipe, RecipeIngredient
|
||||
from ..models.recipes import Recipe, RecipeIngredient, RecipeStatus
|
||||
from ..schemas.recipes import RecipeCreate, RecipeUpdate
|
||||
|
||||
logger = structlog.get_logger()
|
||||
@@ -197,7 +197,7 @@ class RecipeRepository(BaseRepository[Recipe, RecipeCreate, RecipeUpdate]):
|
||||
select(func.count(Recipe.id)).where(
|
||||
and_(
|
||||
Recipe.tenant_id == tenant_id,
|
||||
Recipe.status == "active"
|
||||
Recipe.status == RecipeStatus.ACTIVE
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -231,15 +231,18 @@ class RecipeRepository(BaseRepository[Recipe, RecipeCreate, RecipeUpdate]):
|
||||
.where(Recipe.tenant_id == tenant_id)
|
||||
.group_by(Recipe.category)
|
||||
)
|
||||
categories = dict(category_result.all())
|
||||
category_data = category_result.all()
|
||||
|
||||
# Convert to list of dicts for the schema
|
||||
category_breakdown = [
|
||||
{"category": category or "Uncategorized", "count": count}
|
||||
for category, count in category_data
|
||||
]
|
||||
|
||||
return {
|
||||
"total_recipes": total_recipes,
|
||||
"active_recipes": active_recipes,
|
||||
"signature_recipes": signature_recipes,
|
||||
"seasonal_recipes": seasonal_recipes,
|
||||
"draft_recipes": total_recipes - active_recipes,
|
||||
"categories": categories,
|
||||
"average_difficulty": 3.0, # Could calculate from actual data
|
||||
"total_categories": len(categories)
|
||||
"category_breakdown": category_breakdown
|
||||
}
|
||||
Reference in New Issue
Block a user