diff --git a/backend/cleanup_structure_categories.py b/backend/cleanup_structure_categories.py new file mode 100644 index 00000000..39b1c81e --- /dev/null +++ b/backend/cleanup_structure_categories.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +""" +Clean up structure-based categories that were incorrectly created +This will remove categories like "Guide", "Article", etc. that match content_structure values +""" +import os +import sys +import django + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings') +django.setup() + +from django.db import transaction +from igny8_core.business.content.models import ContentTaxonomy + +# List of structure values that were incorrectly added as categories +STRUCTURE_VALUES = ['Guide', 'Article', 'Listicle', 'How To', 'Tutorial', 'Review', 'Comparison'] + +print("=" * 80) +print("CLEANING UP STRUCTURE-BASED CATEGORIES") +print("=" * 80) + +for structure_name in STRUCTURE_VALUES: + categories = ContentTaxonomy.objects.filter( + taxonomy_type='category', + name=structure_name + ) + + if categories.exists(): + count = categories.count() + print(f"\nRemoving {count} '{structure_name}' categor{'y' if count == 1 else 'ies'}...") + categories.delete() + print(f" ✓ Deleted {count} '{structure_name}' categor{'y' if count == 1 else 'ies'}") + +print("\n" + "=" * 80) +print("CLEANUP COMPLETE") +print("=" * 80) diff --git a/backend/fix_taxonomy_relationships.py b/backend/fix_taxonomy_relationships.py index 8e10b110..bf90f24c 100644 --- a/backend/fix_taxonomy_relationships.py +++ b/backend/fix_taxonomy_relationships.py @@ -42,15 +42,10 @@ for content in content_without_tags: if content.secondary_keywords and isinstance(content.secondary_keywords, list): tags_to_add.extend(content.secondary_keywords[:3]) # Limit to 3 - # Create category based on content_type and cluster + # Create category based on cluster only if content.cluster: categories_to_add.append(content.cluster.name) - # Add content_structure as category - if content.content_structure: - structure_name = content.content_structure.replace('_', ' ').title() - categories_to_add.append(structure_name) - with transaction.atomic(): # Process tags for tag_name in tags_to_add: diff --git a/frontend/src/config/pages/published.config.tsx b/frontend/src/config/pages/published.config.tsx index ababce2a..e1768578 100644 --- a/frontend/src/config/pages/published.config.tsx +++ b/frontend/src/config/pages/published.config.tsx @@ -111,27 +111,7 @@ export function createPublishedPageConfig(params: { ); }, }, - { - key: 'wordpress_status', - label: 'WordPress', - sortable: false, - width: '140px', - render: (_value: any, row: Content) => { - if (row.external_id && row.external_url) { - return ( - - - Published - - ); - } - return ( - - Not Published - - ); - }, - }, + { key: 'content_type', label: 'Type', @@ -166,6 +146,71 @@ export function createPublishedPageConfig(params: { ); }, }, + { + key: 'cluster_name', + label: 'Cluster', + sortable: false, + width: '130px', + render: (_value: any, row: Content) => { + const clusterName = row.cluster_name; + if (!clusterName) { + return -; + } + return ( + + {clusterName} + + ); + }, + }, + { + key: 'tags', + label: 'Tags', + sortable: false, + width: '150px', + render: (_value: any, row: Content) => { + const tags = row.tags || []; + if (!tags || tags.length === 0) { + return -; + } + return ( +
+ {tags.slice(0, 2).map((tag, index) => ( + + {tag} + + ))} + {tags.length > 2 && ( + +{tags.length - 2} + )} +
+ ); + }, + }, + { + key: 'categories', + label: 'Categories', + sortable: false, + width: '150px', + render: (_value: any, row: Content) => { + const categories = row.categories || []; + if (!categories || categories.length === 0) { + return -; + } + return ( +
+ {categories.slice(0, 2).map((category, index) => ( + + {category} + + ))} + {categories.length > 2 && ( + +{categories.length - 2} + )} +
+ ); + }, + }, { key: 'word_count', label: 'Words', diff --git a/frontend/src/config/pages/review.config.tsx b/frontend/src/config/pages/review.config.tsx index 375da9d4..ace86e05 100644 --- a/frontend/src/config/pages/review.config.tsx +++ b/frontend/src/config/pages/review.config.tsx @@ -85,18 +85,23 @@ export function createReviewPageConfig(params: { sortable: false, width: '180px', render: (_value: any, row: Content) => { - const categories = row.taxonomy_terms_data?.filter((t: any) => t.taxonomy_type === 'category') || []; - if (!categories.length) return -; + const categories = row.categories || []; + if (!categories || categories.length === 0) { + return -; + } return (
- {categories.map((cat: any) => ( - {cat.name} + {categories.slice(0, 2).map((category, index) => ( + + {category} + ))} + {categories.length > 2 && ( + +{categories.length - 2} + )}
); }, - toggleable: true, - defaultVisible: true, }, { key: 'tags', @@ -104,18 +109,23 @@ export function createReviewPageConfig(params: { sortable: false, width: '180px', render: (_value: any, row: Content) => { - const tags = row.taxonomy_terms_data?.filter((t: any) => t.taxonomy_type === 'tag') || []; - if (!tags.length) return -; + const tags = row.tags || []; + if (!tags || tags.length === 0) { + return -; + } return (
- {tags.map((tag: any) => ( - {tag.name} + {tags.slice(0, 2).map((tag, index) => ( + + {tag} + ))} + {tags.length > 2 && ( + +{tags.length - 2} + )}
); }, - toggleable: true, - defaultVisible: true, }, { key: 'content_type',