ifixkart-admin/Backend/cleanup_catalog_showcase.py
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

40 lines
1.3 KiB
Python

"""
Script to purge old dummy mock products and keep only the 40 high-quality Cashify refurbished gadgets.
"""
import app.models.db_base
from app.core.database.db_session import SessionLocal
from app.models.ProductModel import Product, ProductVariant, ProductImage
from app.models.CategoryModel import Category
from app.core.database.cache_manager import cache
db = SessionLocal()
# Archive all old dummy mock products (starting with 'Premium ')
dummy_prods = db.query(Product).filter(Product.name.like("Premium %")).all()
dummy_count = len(dummy_prods)
for p in dummy_prods:
p.status = "archived"
db.commit()
# Ensure all 40 Cashify products have status 'active' and accurate categories
active_prods = db.query(Product).filter(Product.name.like("Refurbished %")).all()
for p in active_prods:
p.status = "active"
db.commit()
# Clear cache
cache.clear()
remaining_count = db.query(Product).count()
print(f"Purged {dummy_count} old dummy mock products. Total active catalog size: {remaining_count}")
# Print categories and product counts
cats = db.query(Category).all()
for c in cats:
count = db.query(Product).filter(Product.category_id == c.category_id, Product.status == 'active').count()
print(f"Category: {c.name} ({c.slug}) -> {count} active products")
db.close()