issues fixes related to autaitmioan and ai idea genration
This commit is contained in:
@@ -205,7 +205,10 @@ class GenerateIdeasFunction(BaseAIFunction):
|
||||
elif not isinstance(description, str):
|
||||
description = str(description)
|
||||
|
||||
# Handle target_keywords
|
||||
# Handle primary_focus_keywords (new field)
|
||||
primary_focus_keywords = idea_data.get('primary_focus_keywords', '')
|
||||
|
||||
# Handle target_keywords (covered_keywords from AI)
|
||||
target_keywords = idea_data.get('covered_keywords', '') or idea_data.get('target_keywords', '')
|
||||
|
||||
# Direct mapping - no conversion needed
|
||||
@@ -216,6 +219,7 @@ class GenerateIdeasFunction(BaseAIFunction):
|
||||
ContentIdeas.objects.create(
|
||||
idea_title=idea_data.get('title', 'Untitled Idea'),
|
||||
description=description, # Stored as JSON string
|
||||
primary_focus_keywords=primary_focus_keywords,
|
||||
content_type=content_type,
|
||||
content_structure=content_structure,
|
||||
target_keywords=target_keywords,
|
||||
|
||||
@@ -82,14 +82,41 @@ def run_automation_task(self, run_id: str):
|
||||
try:
|
||||
service = AutomationService.from_run_id(run_id)
|
||||
|
||||
# Run all stages sequentially
|
||||
# Run all stages sequentially, checking for pause/cancel between stages
|
||||
service.run_stage_1()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 1")
|
||||
return
|
||||
|
||||
service.run_stage_2()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 2")
|
||||
return
|
||||
|
||||
service.run_stage_3()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 3")
|
||||
return
|
||||
|
||||
service.run_stage_4()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 4")
|
||||
return
|
||||
|
||||
service.run_stage_5()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 5")
|
||||
return
|
||||
|
||||
service.run_stage_6()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 6")
|
||||
return
|
||||
|
||||
service.run_stage_7()
|
||||
if service.run.status in ['paused', 'cancelled']:
|
||||
logger.info(f"[AutomationTask] Automation {service.run.status} after stage 7")
|
||||
return
|
||||
|
||||
logger.info(f"[AutomationTask] Completed automation run: {run_id}")
|
||||
|
||||
|
||||
@@ -244,7 +244,8 @@ class ContentIdeas(SoftDeletableModel, SiteSectorBaseModel):
|
||||
|
||||
idea_title = models.CharField(max_length=255, db_index=True)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
target_keywords = models.CharField(max_length=500, blank=True) # Comma-separated keywords (legacy)
|
||||
primary_focus_keywords = models.CharField(max_length=500, blank=True, help_text="1-2 main keywords this content targets")
|
||||
target_keywords = models.CharField(max_length=500, blank=True) # Comma-separated keywords (covered_keywords from AI)
|
||||
keyword_objects = models.ManyToManyField(
|
||||
'Keywords',
|
||||
blank=True,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated migration for adding primary_focus_keywords field
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('planner', '0010_add_taxonomy_soft_delete_and_keyword_fk_cascade'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Add primary_focus_keywords field to ContentIdeas
|
||||
migrations.AddField(
|
||||
model_name='contentideas',
|
||||
name='primary_focus_keywords',
|
||||
field=models.CharField(blank=True, help_text='1-2 main keywords this content targets', max_length=500),
|
||||
),
|
||||
]
|
||||
@@ -245,6 +245,7 @@ class ContentIdeasSerializer(serializers.ModelSerializer):
|
||||
'id',
|
||||
'idea_title',
|
||||
'description',
|
||||
'primary_focus_keywords',
|
||||
'content_type',
|
||||
'content_structure',
|
||||
'target_keywords',
|
||||
|
||||
Reference in New Issue
Block a user