keywrods status fixes
This commit is contained in:
20
backend/check_recent_keywords.py
Normal file
20
backend/check_recent_keywords.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Check recent keyword creation"""
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
from igny8_core.business.planning.models import Keywords
|
||||||
|
from django.utils import timezone
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
recent = timezone.now() - timedelta(hours=24)
|
||||||
|
recent_keywords = Keywords.objects.filter(created_at__gte=recent)
|
||||||
|
|
||||||
|
print(f'Keywords created in last 24 hours: {recent_keywords.count()}')
|
||||||
|
if recent_keywords.exists():
|
||||||
|
print('\nRecent keyword statuses:')
|
||||||
|
for k in recent_keywords[:10]:
|
||||||
|
print(f' ID {k.id}: status={k.status}, created={k.created_at}')
|
||||||
22
backend/fix_cluster_status.py
Normal file
22
backend/fix_cluster_status.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Fix remaining cluster with old status"""
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
from igny8_core.business.planning.models import Clusters
|
||||||
|
|
||||||
|
cluster = Clusters.objects.filter(status='active').first()
|
||||||
|
if cluster:
|
||||||
|
print(f"Found cluster: ID={cluster.id}, name={cluster.name}, status={cluster.status}")
|
||||||
|
print(f"Ideas count: {cluster.ideas.count()}")
|
||||||
|
if cluster.ideas.exists():
|
||||||
|
cluster.status = 'mapped'
|
||||||
|
else:
|
||||||
|
cluster.status = 'new'
|
||||||
|
cluster.save()
|
||||||
|
print(f"Updated to: {cluster.status}")
|
||||||
|
else:
|
||||||
|
print("No clusters with 'active' status found")
|
||||||
26
backend/sync_idea_status.py
Normal file
26
backend/sync_idea_status.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
Sync idea status from completed tasks
|
||||||
|
One-time script to fix existing data
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
from igny8_core.business.content.models import Tasks
|
||||||
|
from igny8_core.business.planning.models import ContentIdeas
|
||||||
|
|
||||||
|
# Find all completed tasks with ideas
|
||||||
|
completed_tasks = Tasks.objects.filter(status='completed', idea__isnull=False)
|
||||||
|
|
||||||
|
synced = 0
|
||||||
|
for task in completed_tasks:
|
||||||
|
if task.idea and task.idea.status != 'completed':
|
||||||
|
task.idea.status = 'completed'
|
||||||
|
task.idea.save(update_fields=['status', 'updated_at'])
|
||||||
|
synced += 1
|
||||||
|
print(f"Synced idea {task.idea.id} to completed (from task {task.id})")
|
||||||
|
|
||||||
|
print(f"\nTotal synced: {synced} ideas to completed status")
|
||||||
71
backend/verify_status_fixes.py
Normal file
71
backend/verify_status_fixes.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Verify all status fixes"""
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
|
||||||
|
django.setup()
|
||||||
|
|
||||||
|
from igny8_core.business.planning.models import Keywords, Clusters, ContentIdeas
|
||||||
|
from igny8_core.business.content.models import Tasks
|
||||||
|
from django.db.models import Count
|
||||||
|
|
||||||
|
print("=" * 60)
|
||||||
|
print("STATUS VERIFICATION REPORT")
|
||||||
|
print("=" * 60)
|
||||||
|
|
||||||
|
# Keywords
|
||||||
|
print("\n1. KEYWORDS STATUS:")
|
||||||
|
kw_status = Keywords.objects.values('status').annotate(count=Count('id')).order_by('status')
|
||||||
|
for item in kw_status:
|
||||||
|
print(f" {item['status']}: {item['count']}")
|
||||||
|
print(f" Total: {Keywords.objects.count()}")
|
||||||
|
|
||||||
|
# Clusters
|
||||||
|
print("\n2. CLUSTERS STATUS:")
|
||||||
|
cl_status = Clusters.objects.values('status').annotate(count=Count('id')).order_by('status')
|
||||||
|
for item in cl_status:
|
||||||
|
print(f" {item['status']}: {item['count']}")
|
||||||
|
print(f" Total: {Clusters.objects.count()}")
|
||||||
|
|
||||||
|
# Content Ideas
|
||||||
|
print("\n3. IDEAS STATUS:")
|
||||||
|
idea_status = ContentIdeas.objects.values('status').annotate(count=Count('id')).order_by('status')
|
||||||
|
for item in idea_status:
|
||||||
|
print(f" {item['status']}: {item['count']}")
|
||||||
|
print(f" Total: {ContentIdeas.objects.count()}")
|
||||||
|
|
||||||
|
# Verify idea-task sync
|
||||||
|
print("\n4. IDEA-TASK STATUS SYNC:")
|
||||||
|
completed_tasks = Tasks.objects.filter(status='completed', idea__isnull=False)
|
||||||
|
mismatched = 0
|
||||||
|
for task in completed_tasks:
|
||||||
|
if task.idea and task.idea.status != 'completed':
|
||||||
|
mismatched += 1
|
||||||
|
print(f" MISMATCH: Task {task.id} completed, Idea {task.idea.id} is {task.idea.status}")
|
||||||
|
|
||||||
|
if mismatched == 0:
|
||||||
|
print(f" ✓ All {completed_tasks.count()} completed tasks have ideas with 'completed' status")
|
||||||
|
else:
|
||||||
|
print(f" ✗ {mismatched} mismatches found")
|
||||||
|
|
||||||
|
# Check for old status values
|
||||||
|
print("\n5. OLD STATUS VALUES CHECK:")
|
||||||
|
old_keywords = Keywords.objects.filter(status__in=['pending', 'active', 'archived']).count()
|
||||||
|
old_clusters = Clusters.objects.filter(status__in=['active']).exclude(status='mapped').exclude(status='new').count()
|
||||||
|
old_ideas = ContentIdeas.objects.filter(status__in=['scheduled', 'published']).count()
|
||||||
|
|
||||||
|
if old_keywords == 0 and old_clusters == 0 and old_ideas == 0:
|
||||||
|
print(" ✓ No old status values found")
|
||||||
|
else:
|
||||||
|
print(f" ✗ Found old values:")
|
||||||
|
if old_keywords > 0:
|
||||||
|
print(f" Keywords with pending/active/archived: {old_keywords}")
|
||||||
|
if old_clusters > 0:
|
||||||
|
print(f" Clusters with old 'active': {old_clusters}")
|
||||||
|
if old_ideas > 0:
|
||||||
|
print(f" Ideas with scheduled/published: {old_ideas}")
|
||||||
|
|
||||||
|
print("\n" + "=" * 60)
|
||||||
|
print("VERIFICATION COMPLETE")
|
||||||
|
print("=" * 60)
|
||||||
@@ -36,9 +36,8 @@ export const bulkActionModalConfigs: Record<string, BulkActionModalConfig> = {
|
|||||||
confirmText: 'Update Status',
|
confirmText: 'Update Status',
|
||||||
itemNamePlural: 'keywords',
|
itemNamePlural: 'keywords',
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ value: 'active', label: 'Active' },
|
{ value: 'new', label: 'New' },
|
||||||
{ value: 'pending', label: 'Pending' },
|
{ value: 'mapped', label: 'Mapped' },
|
||||||
{ value: 'archived', label: 'Archived' },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -55,8 +54,8 @@ export const bulkActionModalConfigs: Record<string, BulkActionModalConfig> = {
|
|||||||
confirmText: 'Update Status',
|
confirmText: 'Update Status',
|
||||||
itemNamePlural: 'clusters',
|
itemNamePlural: 'clusters',
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ value: 'active', label: 'Active' },
|
{ value: 'new', label: 'New' },
|
||||||
{ value: 'inactive', label: 'Inactive' },
|
{ value: 'mapped', label: 'Mapped' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -74,8 +73,8 @@ export const bulkActionModalConfigs: Record<string, BulkActionModalConfig> = {
|
|||||||
itemNamePlural: 'ideas',
|
itemNamePlural: 'ideas',
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ value: 'new', label: 'New' },
|
{ value: 'new', label: 'New' },
|
||||||
{ value: 'scheduled', label: 'Scheduled' },
|
{ value: 'queued', label: 'Queued' },
|
||||||
{ value: 'published', label: 'Published' },
|
{ value: 'completed', label: 'Completed' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user