Recovered state: integrated TrendSurferAgent, restored frontend/backend files, and cleaned up recovery scripts

This commit is contained in:
ajaysi
2026-02-08 13:56:57 +05:30
parent 1db10ccd0f
commit e404a86502
333 changed files with 42223 additions and 10875 deletions

View File

@@ -131,6 +131,11 @@ class DatabaseSetup:
from services.database import engine
from sqlalchemy import inspect
if engine is None:
if verbose:
print(" ⚠️ Global engine is None (Multi-tenant mode), skipping global table verification")
return True
inspector = inspect(engine)
tables = inspector.get_table_names()
@@ -181,20 +186,9 @@ class DatabaseSetup:
def _setup_monitoring_tables(self) -> bool:
"""Set up API monitoring tables."""
try:
sys.path.append(str(Path(__file__).parent.parent))
from scripts.create_monitoring_tables import create_monitoring_tables
if create_monitoring_tables():
print(" ✅ API monitoring tables created")
return True
else:
print(" ⚠️ API monitoring setup failed")
return True # Non-critical
except Exception as e:
print(f" ⚠️ Monitoring setup failed: {e}")
return True # Non-critical
# Reuse the existing method that uses SQLAlchemy metadata
# This avoids the script dependency that requires user_id
return self._create_monitoring_tables()
def _setup_billing_tables(self) -> bool:
"""Set up billing and subscription tables."""
@@ -203,17 +197,23 @@ class DatabaseSetup:
from scripts.create_billing_tables import create_billing_tables, check_existing_tables
from services.database import engine
# Check if engine is available (it might be None in multi-tenant mode)
if engine is None:
# In multi-tenant mode, we can't setup global billing tables
# They will be created per-user when they are initialized
return True
# Check if tables already exist
if check_existing_tables(engine):
logger.debug("✅ Billing tables already exist")
return True
if create_billing_tables():
logger.debug("✅ Billing tables created")
return True
else:
logger.warning("Billing setup failed")
return True # Non-critical
# For global setup, we can't call create_billing_tables() without user_id
# But if engine is not None, it implies we have a global DB.
# However, the script is designed for user_id.
# We'll skip this call to avoid the TypeError and rely on per-user init.
logger.debug(" Skipping global billing table creation (handled per-user)")
return True
except Exception as e:
logger.warning(f"Billing setup failed: {e}")

View File

@@ -364,7 +364,7 @@ class OnboardingManager:
raise HTTPException(status_code=500, detail=str(e))
@self.app.get("/api/onboarding/business-info/user/{user_id}")
async def business_info_get_by_user(user_id: int):
async def business_info_get_by_user(user_id: str):
"""Get business information by user ID."""
try:
return await get_business_info_by_user(user_id)

View File

@@ -6,6 +6,7 @@ Handles FastAPI router inclusion and management.
from fastapi import FastAPI
from loguru import logger
from typing import List, Dict, Any, Optional
import os
class RouterManager:
@@ -18,7 +19,6 @@ class RouterManager:
def include_router_safely(self, router, router_name: str = None) -> bool:
"""Include a router safely with error handling."""
import os
verbose = os.getenv("ALWRITY_VERBOSE", "false").lower() == "true"
try:
@@ -37,6 +37,7 @@ class RouterManager:
def include_core_routers(self) -> bool:
"""Include core application routers."""
# Import os locally to avoid UnboundLocalError if it's shadowed
import os
verbose = os.getenv("ALWRITY_VERBOSE", "false").lower() == "true"
@@ -55,6 +56,13 @@ class RouterManager:
# Step 3 Research router (core onboarding functionality)
from api.onboarding_utils.step3_routes import router as step3_research_router
self.include_router_safely(step3_research_router, "step3_research")
# Step 4 Persona and Asset routers
from api.onboarding_utils.step4_asset_routes import router as step4_asset_router
self.include_router_safely(step4_asset_router, "step4_assets")
from api.onboarding_utils.step4_persona_routes_optimized import router as step4_persona_router
self.include_router_safely(step4_persona_router, "step4_persona")
# GSC router
from routers.gsc_auth import router as gsc_auth_router