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

@@ -52,7 +52,7 @@ export default function Keywords() {
const [searchTerm, setSearchTerm] = useState('');
const [statusFilter, setStatusFilter] = useState('');
const [clusterFilter, setClusterFilter] = useState('');
const [intentFilter, setIntentFilter] = useState('');
const [countryFilter, setCountryFilter] = useState('');
const [difficultyFilter, setDifficultyFilter] = useState('');
const [volumeMin, setVolumeMin] = useState<number | ''>('');
const [volumeMax, setVolumeMax] = useState<number | ''>('');
@@ -81,7 +81,7 @@ export default function Keywords() {
keyword: '',
volume: null,
difficulty: null,
intent: 'informational',
country: 'US',
cluster_id: null,
status: 'new',
});
@@ -156,7 +156,7 @@ export default function Keywords() {
...(searchTerm && { search: searchTerm }),
...(statusFilter && { status: statusFilter }),
...(clusterFilter && { cluster_id: clusterFilter }),
...(intentFilter && { intent: intentFilter }),
...(countryFilter && { country: countryFilter }),
...(activeSector?.id && { sector_id: activeSector.id }),
page: currentPage,
page_size: pageSize || 10, // Ensure we always send a page_size
@@ -200,7 +200,7 @@ export default function Keywords() {
setShowContent(true);
setLoading(false);
}
}, [currentPage, statusFilter, clusterFilter, intentFilter, difficultyFilter, volumeMin, volumeMax, sortBy, sortDirection, searchTerm, activeSite, activeSector, pageSize]);
}, [currentPage, statusFilter, clusterFilter, countryFilter, difficultyFilter, volumeMin, volumeMax, sortBy, sortDirection, searchTerm, activeSite, activeSector, pageSize]);
// Listen for site and sector changes and refresh data
useEffect(() => {
@@ -324,8 +324,8 @@ export default function Keywords() {
toast.error('Please select at least one keyword to cluster');
return;
}
if (ids.length > 20) {
toast.error('Maximum 20 keywords allowed for clustering');
if (ids.length > 50) {
toast.error('Maximum 50 keywords allowed for clustering');
return;
}
@@ -536,7 +536,7 @@ export default function Keywords() {
keyword: '',
volume: null,
difficulty: null,
intent: 'informational',
country: 'US',
cluster_id: null,
status: 'new',
});
@@ -605,8 +605,8 @@ export default function Keywords() {
setSearchTerm,
statusFilter,
setStatusFilter,
intentFilter,
setIntentFilter,
countryFilter,
setCountryFilter,
difficultyFilter,
setDifficultyFilter,
clusterFilter,
@@ -632,7 +632,7 @@ export default function Keywords() {
formData,
searchTerm,
statusFilter,
intentFilter,
countryFilter,
difficultyFilter,
clusterFilter,
volumeMin,
@@ -776,7 +776,7 @@ export default function Keywords() {
keyword: keyword.keyword,
volume: keyword.volume,
difficulty: keyword.difficulty,
intent: keyword.intent,
country: keyword.country,
cluster_id: keyword.cluster_id,
status: keyword.status,
});
@@ -807,7 +807,7 @@ export default function Keywords() {
filterValues={{
search: searchTerm,
status: statusFilter,
intent: intentFilter,
country: countryFilter,
difficulty: difficultyFilter,
cluster_id: clusterFilter,
volumeMin: volumeMin,
@@ -823,8 +823,8 @@ export default function Keywords() {
} else if (key === 'status') {
setStatusFilter(stringValue);
setCurrentPage(1);
} else if (key === 'intent') {
setIntentFilter(stringValue);
} else if (key === 'country') {
setCountryFilter(stringValue);
setCurrentPage(1);
} else if (key === 'difficulty') {
setDifficultyFilter(stringValue);
@@ -868,7 +868,7 @@ export default function Keywords() {
search: searchTerm,
status: statusFilter,
cluster_id: clusterFilter,
intent: intentFilter,
country: countryFilter,
difficulty: difficultyFilter,
};
await handleExport('csv', filterValues);
@@ -903,7 +903,7 @@ export default function Keywords() {
setSearchTerm('');
setStatusFilter('');
setClusterFilter('');
setIntentFilter('');
setCountryFilter('');
setDifficultyFilter('');
setVolumeMin('');
setVolumeMax('');