refactor-migration again

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-26 15:12:14 +00:00
parent 2ef98b5113
commit f88aae78b1
23 changed files with 942 additions and 211 deletions

View File

@@ -208,29 +208,16 @@ class GenerateIdeasFunction(BaseAIFunction):
# Handle target_keywords
target_keywords = idea_data.get('covered_keywords', '') or idea_data.get('target_keywords', '')
# Map content_type and content_structure to ContentIdeas fields
# AI returns: content_type (post/page/product/service) → site_entity_type
# AI returns: content_structure (article/guide/review/comparison) → cluster_role (hub/supporting/attribute)
site_entity_type = idea_data.get('content_type', 'post') # post, page, product, service
# Map content_structure to cluster_role
# Direct mapping - no conversion needed
content_type = idea_data.get('content_type', 'post')
content_structure = idea_data.get('content_structure', 'article')
structure_to_role = {
'article': 'hub',
'guide': 'supporting',
'review': 'supporting',
'comparison': 'attribute',
'listicle': 'supporting',
'product_page': 'attribute',
}
cluster_role = structure_to_role.get(content_structure, 'hub')
# Create ContentIdeas record
ContentIdeas.objects.create(
idea_title=idea_data.get('title', 'Untitled Idea'),
description=description, # Stored as JSON string
site_entity_type=site_entity_type,
cluster_role=cluster_role,
content_type=content_type,
content_structure=content_structure,
target_keywords=target_keywords,
keyword_cluster=cluster,
estimated_word_count=idea_data.get('estimated_word_count', 1500),