Refactor keyword handling: Replace 'intent' with 'country' across backend and frontend

- Updated AutomationService to include estimated_word_count.
- Increased stage_1_batch_size from 20 to 50 in AutomationViewSet.
- Changed Keywords model to replace 'intent' property with 'country'.
- Adjusted ClusteringService to allow a maximum of 50 keywords for clustering.
- Modified admin and management commands to remove 'intent' and use 'country' instead.
- Updated serializers to reflect the change from 'intent' to 'country'.
- Adjusted views and filters to use 'country' instead of 'intent'.
- Updated frontend forms, filters, and pages to replace 'intent' with 'country'.
- Added migration to remove 'intent' field and add 'country' field to SeedKeyword model.
This commit is contained in:
IGNY8 VPS (Salman)
2025-12-17 07:37:36 +00:00
parent 9f826c92f8
commit 7ad06c6227
30 changed files with 240 additions and 205 deletions

View File

@@ -55,7 +55,7 @@ class KeywordViewSet(SiteSectorModelViewSet):
ordering = ['-created_at'] # Default ordering (newest first)
# Filter configuration - filter by status, cluster_id, and seed_keyword fields
filterset_fields = ['status', 'cluster_id', 'seed_keyword__intent', 'seed_keyword_id']
filterset_fields = ['status', 'cluster_id', 'seed_keyword__country', 'seed_keyword_id']
def get_queryset(self):
"""
@@ -475,7 +475,7 @@ class KeywordViewSet(SiteSectorModelViewSet):
writer = csv.writer(response)
# Header row
writer.writerow(['ID', 'Keyword', 'Volume', 'Difficulty', 'Intent', 'Status', 'Cluster ID', 'Created At'])
writer.writerow(['ID', 'Keyword', 'Volume', 'Difficulty', 'Country', 'Status', 'Cluster ID', 'Created At'])
# Data rows
for keyword in keywords:
@@ -484,7 +484,7 @@ class KeywordViewSet(SiteSectorModelViewSet):
keyword.keyword,
keyword.volume,
keyword.difficulty,
keyword.intent,
keyword.country,
keyword.status,
keyword.cluster_id or '',
keyword.created_at.isoformat() if keyword.created_at else '',
@@ -631,12 +631,13 @@ class KeywordViewSet(SiteSectorModelViewSet):
skipped_count += 1
continue
# Create keyword
# Note: This direct creation bypasses seed_keyword linkage
# Keywords should ideally be created through seed_keyword FK
# Country comes from seed_keyword.country property
Keywords.objects.create(
keyword=keyword_text,
volume=int(row.get('volume', 0) or 0),
difficulty=int(row.get('difficulty', 0) or 0),
intent=row.get('intent', 'informational') or 'informational',
status=row.get('status', 'new') or 'new',
site=site,
sector=sector,
@@ -1193,6 +1194,7 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
content_structure=idea.content_structure or 'article',
taxonomy_term=None, # Can be set later if taxonomy is available
keywords=keywords_str, # Comma-separated keywords string
word_count=idea.estimated_word_count, # Copy word count from idea
status='queued',
account=idea.account,
site=idea.site,