433
This commit is contained in:
38
backend/cleanup_structure_categories.py
Normal file
38
backend/cleanup_structure_categories.py
Normal file
@@ -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)
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user