From 23e628079b96d640ee47a491b6a23968f8f70943 Mon Sep 17 00:00:00 2001 From: "IGNY8 VPS (Salman)" Date: Wed, 3 Dec 2025 05:56:41 +0000 Subject: [PATCH] keywrods status fixes --- backend/check_recent_keywords.py | 20 ++++++ backend/fix_cluster_status.py | 22 ++++++ backend/sync_idea_status.py | 26 +++++++ backend/verify_status_fixes.py | 71 +++++++++++++++++++ .../config/pages/bulk-action-modal.config.ts | 13 ++-- 5 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 backend/check_recent_keywords.py create mode 100644 backend/fix_cluster_status.py create mode 100644 backend/sync_idea_status.py create mode 100644 backend/verify_status_fixes.py diff --git a/backend/check_recent_keywords.py b/backend/check_recent_keywords.py new file mode 100644 index 00000000..f4bdd0c5 --- /dev/null +++ b/backend/check_recent_keywords.py @@ -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}') diff --git a/backend/fix_cluster_status.py b/backend/fix_cluster_status.py new file mode 100644 index 00000000..cbda73d4 --- /dev/null +++ b/backend/fix_cluster_status.py @@ -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") diff --git a/backend/sync_idea_status.py b/backend/sync_idea_status.py new file mode 100644 index 00000000..5cb20627 --- /dev/null +++ b/backend/sync_idea_status.py @@ -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") diff --git a/backend/verify_status_fixes.py b/backend/verify_status_fixes.py new file mode 100644 index 00000000..2b019016 --- /dev/null +++ b/backend/verify_status_fixes.py @@ -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) diff --git a/frontend/src/config/pages/bulk-action-modal.config.ts b/frontend/src/config/pages/bulk-action-modal.config.ts index fb21b0a3..34ce3d79 100644 --- a/frontend/src/config/pages/bulk-action-modal.config.ts +++ b/frontend/src/config/pages/bulk-action-modal.config.ts @@ -36,9 +36,8 @@ export const bulkActionModalConfigs: Record = { confirmText: 'Update Status', itemNamePlural: 'keywords', statusOptions: [ - { value: 'active', label: 'Active' }, - { value: 'pending', label: 'Pending' }, - { value: 'archived', label: 'Archived' }, + { value: 'new', label: 'New' }, + { value: 'mapped', label: 'Mapped' }, ], }, }, @@ -55,8 +54,8 @@ export const bulkActionModalConfigs: Record = { confirmText: 'Update Status', itemNamePlural: 'clusters', statusOptions: [ - { value: 'active', label: 'Active' }, - { value: 'inactive', label: 'Inactive' }, + { value: 'new', label: 'New' }, + { value: 'mapped', label: 'Mapped' }, ], }, }, @@ -74,8 +73,8 @@ export const bulkActionModalConfigs: Record = { itemNamePlural: 'ideas', statusOptions: [ { value: 'new', label: 'New' }, - { value: 'scheduled', label: 'Scheduled' }, - { value: 'published', label: 'Published' }, + { value: 'queued', label: 'Queued' }, + { value: 'completed', label: 'Completed' }, ], }, },