diff --git a/apps/coordinator-api/src/app/main.py b/apps/coordinator-api/src/app/main.py index 6a7603ce..bb034101 100755 --- a/apps/coordinator-api/src/app/main.py +++ b/apps/coordinator-api/src/app/main.py @@ -288,7 +288,6 @@ def create_app() -> FastAPI: app.include_router(services, prefix="/v1") app.include_router(users, prefix="/v1") app.include_router(exchange, prefix="/v1") - app.include_router(marketplace_offers, prefix="/v1") app.include_router(payments, prefix="/v1") app.include_router(web_vitals, prefix="/v1") app.include_router(edge_gpu) @@ -309,6 +308,9 @@ def create_app() -> FastAPI: app.include_router(developer_platform, prefix="/v1") app.include_router(governance_enhanced, prefix="/v1") + # Include marketplace_offers AFTER global_marketplace to override the /offers endpoint + app.include_router(marketplace_offers, prefix="/v1") + # Add blockchain router for CLI compatibility print(f"Adding blockchain router: {blockchain}") app.include_router(blockchain, prefix="/v1") diff --git a/apps/coordinator-api/src/app/services/marketplace.py b/apps/coordinator-api/src/app/services/marketplace.py index fd97e56b..555d8577 100755 --- a/apps/coordinator-api/src/app/services/marketplace.py +++ b/apps/coordinator-api/src/app/services/marketplace.py @@ -36,11 +36,11 @@ class MarketplaceService: stmt = stmt.where(MarketplaceOffer.status == normalised) stmt = stmt.offset(offset).limit(limit) - offers = self.session.execute(stmt).all() + offers = self.session.execute(stmt).scalars().all() return [self._to_offer_view(o) for o in offers] def get_stats(self) -> MarketplaceStatsView: - offers = self.session.execute(select(MarketplaceOffer)).all() + offers = self.session.execute(select(MarketplaceOffer)).scalars().all() open_offers = [offer for offer in offers if offer.status == "open"] total_offers = len(offers) diff --git a/apps/coordinator-api/src/app/storage/db.py b/apps/coordinator-api/src/app/storage/db.py index 36594126..a045e329 100755 --- a/apps/coordinator-api/src/app/storage/db.py +++ b/apps/coordinator-api/src/app/storage/db.py @@ -62,7 +62,13 @@ def get_engine() -> Engine: return _engine -from app.domain import * +# Import only essential models for database initialization +# This avoids loading all domain models which causes 2+ minute startup delays +from app.domain import ( + Job, Miner, MarketplaceOffer, MarketplaceBid, + User, Wallet, Transaction, UserSession, + JobPayment, PaymentEscrow, JobReceipt +) def init_db() -> Engine: """Initialize database tables and ensure data directory exists."""