refactor(arch): eliminate all cross-module model imports in service layer
Some checks failed
Some checks failed
Enforce MOD-025/MOD-026 rules: zero top-level cross-module model imports remain in any service file. All 66 files migrated using deferred import patterns (method-body, _get_model() helpers, instance-cached self._Model) and new cross-module service methods in tenancy. Documentation updated with Pattern 6 (deferred imports), migration plan marked complete, and violations status reflects 84→0 service-layer violations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -125,18 +125,11 @@ class CustomerMetricsProvider:
|
||||
For platforms, aggregates customer data across all stores.
|
||||
"""
|
||||
from app.modules.customers.models import Customer
|
||||
from app.modules.tenancy.models import StorePlatform
|
||||
from app.modules.tenancy.services.platform_service import platform_service
|
||||
|
||||
try:
|
||||
# Get all store IDs for this platform using StorePlatform junction table
|
||||
store_ids = (
|
||||
db.query(StorePlatform.store_id)
|
||||
.filter(
|
||||
StorePlatform.platform_id == platform_id,
|
||||
StorePlatform.is_active == True,
|
||||
)
|
||||
.subquery()
|
||||
)
|
||||
# Get all store IDs for this platform via platform service
|
||||
store_ids = platform_service.get_store_ids_for_platform(db, platform_id)
|
||||
|
||||
# Total customers across all stores
|
||||
total_customers = (
|
||||
@@ -208,14 +201,11 @@ class CustomerMetricsProvider:
|
||||
Aggregates customer counts across all stores owned by the merchant.
|
||||
"""
|
||||
from app.modules.customers.models import Customer
|
||||
from app.modules.tenancy.models import Store
|
||||
from app.modules.tenancy.services.store_service import store_service
|
||||
|
||||
try:
|
||||
merchant_store_ids = (
|
||||
db.query(Store.id)
|
||||
.filter(Store.merchant_id == merchant_id)
|
||||
.subquery()
|
||||
)
|
||||
merchant_stores = store_service.get_stores_by_merchant_id(db, merchant_id)
|
||||
merchant_store_ids = [s.id for s in merchant_stores]
|
||||
|
||||
total_customers = (
|
||||
db.query(Customer)
|
||||
|
||||
Reference in New Issue
Block a user