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

@@ -58,7 +58,7 @@ export default function IndustriesSectorsKeywords() {
// Filter state
const [searchTerm, setSearchTerm] = useState('');
const [intentFilter, setIntentFilter] = useState('');
const [countryFilter, setCountryFilter] = useState('');
const [difficultyFilter, setDifficultyFilter] = useState('');
// Check if user is admin/superuser (role is 'admin' or 'developer')
@@ -153,7 +153,7 @@ export default function IndustriesSectorsKeywords() {
}
if (searchTerm) baseFilters.search = searchTerm;
if (intentFilter) baseFilters.intent = intentFilter;
if (countryFilter) baseFilters.country = countryFilter;
// Fetch ALL pages to get complete dataset
let allResults: SeedKeyword[] = [];
@@ -215,9 +215,9 @@ export default function IndustriesSectorsKeywords() {
} else if (sortBy === 'difficulty') {
aVal = a.difficulty;
bVal = b.difficulty;
} else if (sortBy === 'intent') {
aVal = a.intent.toLowerCase();
bVal = b.intent.toLowerCase();
} else if (sortBy === 'country') {
aVal = a.country.toLowerCase();
bVal = b.country.toLowerCase();
} else {
return 0;
}
@@ -249,7 +249,7 @@ export default function IndustriesSectorsKeywords() {
setTotalCount(0);
setTotalPages(1);
}
}, [activeSite, activeSector, currentPage, pageSize, searchTerm, intentFilter, difficultyFilter, sortBy, sortDirection, toast]);
}, [activeSite, activeSector, currentPage, pageSize, searchTerm, countryFilter, difficultyFilter, sortBy, sortDirection, toast]);
// Load data on mount and when filters change
useEffect(() => {
@@ -521,28 +521,18 @@ export default function IndustriesSectorsKeywords() {
},
},
{
key: 'intent',
label: 'Intent',
key: 'country',
label: 'Country',
sortable: true,
sortField: 'intent',
sortField: 'country',
render: (value: string) => {
const getIntentColor = (intent: string) => {
const lowerIntent = intent?.toLowerCase() || '';
if (lowerIntent === 'transactional' || lowerIntent === 'commercial') {
return 'success';
} else if (lowerIntent === 'navigational') {
return 'warning';
}
return 'info';
};
return (
<Badge
color={getIntentColor(value)}
color="info"
size="sm"
variant={value?.toLowerCase() === 'informational' ? 'light' : undefined}
variant="light"
>
{value}
{value || '-'}
</Badge>
);
},
@@ -584,15 +574,18 @@ export default function IndustriesSectorsKeywords() {
placeholder: 'Search keywords...',
},
{
key: 'intent',
label: 'Intent',
key: 'country',
label: 'Country',
type: 'select' as const,
options: [
{ value: '', label: 'All Intent' },
{ value: 'informational', label: 'Informational' },
{ value: 'navigational', label: 'Navigational' },
{ value: 'transactional', label: 'Transactional' },
{ value: 'commercial', label: 'Commercial' },
{ value: '', label: 'All Countries' },
{ value: 'US', label: 'United States' },
{ value: 'CA', label: 'Canada' },
{ value: 'GB', label: 'United Kingdom' },
{ value: 'AE', label: 'United Arab Emirates' },
{ value: 'AU', label: 'Australia' },
{ value: 'IN', label: 'India' },
{ value: 'PK', label: 'Pakistan' },
],
},
{
@@ -691,7 +684,7 @@ export default function IndustriesSectorsKeywords() {
filters={pageConfig.filters}
filterValues={{
search: searchTerm,
intent: intentFilter,
country: countryFilter,
difficulty: difficultyFilter,
}}
onFilterChange={(key, value) => {
@@ -699,8 +692,8 @@ export default function IndustriesSectorsKeywords() {
if (key === 'search') {
setSearchTerm(stringValue);
} else if (key === 'intent') {
setIntentFilter(stringValue);
} else if (key === 'country') {
setCountryFilter(stringValue);
setCurrentPage(1);
} else if (key === 'difficulty') {
setDifficultyFilter(stringValue);
@@ -762,7 +755,7 @@ export default function IndustriesSectorsKeywords() {
<div>
<Label htmlFor="import-file">Upload CSV File</Label>
<p className="text-sm text-gray-500 dark:text-gray-400 mb-2">
Expected columns: keyword, volume, difficulty, intent, industry_name, sector_name
Expected columns: keyword, volume, difficulty, country, industry_name, sector_name
</p>
<FileInput
accept=".csv"