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

@@ -582,7 +582,7 @@ export interface KeywordFilters {
search?: string;
status?: string;
cluster_id?: string;
intent?: string;
country?: string;
difficulty_min?: number;
difficulty_max?: number;
volume_min?: number;
@@ -608,7 +608,7 @@ export interface Keyword {
keyword: string; // Read-only property from seed_keyword
volume: number; // Read-only property from seed_keyword or volume_override
difficulty: number; // Read-only property from seed_keyword or difficulty_override
intent: string; // Read-only property from seed_keyword
country: string; // Read-only property from seed_keyword
volume_override?: number | null;
difficulty_override?: number | null;
cluster_id: number | null;
@@ -623,7 +623,7 @@ export interface KeywordCreateData {
keyword?: string; // For creating new custom keywords
volume?: number | null; // For custom keywords
difficulty?: number | null; // For custom keywords
intent?: string; // For custom keywords
country?: string; // For custom keywords
seed_keyword_id?: number; // For linking existing seed keywords (optional)
volume_override?: number | null;
difficulty_override?: number | null;
@@ -661,7 +661,7 @@ export async function fetchKeywords(filters: KeywordFilters = {}): Promise<Keywo
if (filters.search) params.append('search', filters.search);
if (filters.status) params.append('status', filters.status);
if (filters.cluster_id) params.append('cluster_id', filters.cluster_id);
if (filters.intent) params.append('seed_keyword__intent', filters.intent);
if (filters.country) params.append('seed_keyword__country', filters.country);
if (filters.difficulty_min !== undefined) params.append('difficulty_min', filters.difficulty_min.toString());
if (filters.difficulty_max !== undefined) params.append('difficulty_max', filters.difficulty_max.toString());
if (filters.volume_min !== undefined) params.append('volume_min', filters.volume_min.toString());
@@ -695,12 +695,12 @@ export async function createKeyword(data: KeywordCreateData): Promise<Keyword> {
requestData.custom_keyword = data.keyword;
requestData.custom_volume = data.volume;
requestData.custom_difficulty = data.difficulty;
requestData.custom_intent = data.intent || 'informational';
requestData.custom_country = data.country || 'US';
// Remove the frontend-only fields
delete requestData.keyword;
delete requestData.volume;
delete requestData.difficulty;
delete requestData.intent;
delete requestData.country;
}
return fetchAPI('/v1/planner/keywords/', {
@@ -2073,8 +2073,8 @@ export interface SeedKeyword {
sector_slug: string;
volume: number;
difficulty: number;
intent: string;
intent_display: string;
country: string;
country_display: string;
is_active: boolean;
created_at: string;
updated_at: string;
@@ -2090,7 +2090,7 @@ export interface SeedKeywordResponse {
export async function fetchSeedKeywords(filters?: {
industry?: number;
sector?: number;
intent?: string;
country?: string;
search?: string;
page?: number;
page_size?: number;
@@ -2105,7 +2105,7 @@ export async function fetchSeedKeywords(filters?: {
params.append('sector', filters.sector.toString());
params.append('sector_id', filters.sector.toString()); // Also send sector_id for get_queryset
}
if (filters?.intent) params.append('intent', filters.intent);
if (filters?.country) params.append('country', filters.country);
if (filters?.search) params.append('search', filters.search);
if (filters?.page) params.append('page', filters.page.toString());
if (filters?.page_size) params.append('page_size', filters.page_size.toString());