remove old import

This commit is contained in:
HotSwapp
2025-08-14 21:27:34 -05:00
parent bfc04a6909
commit 679ab4446a
17 changed files with 2016 additions and 557 deletions

View File

@@ -16,6 +16,8 @@ from app.auth.security import get_current_user
from app.services.cache import invalidate_search_cache
from app.services.customers_search import apply_customer_filters, apply_customer_sorting, prepare_customer_csv_rows
from app.services.query_utils import apply_sorting, paginate_with_total
from app.utils.logging import app_logger
from app.utils.database import db_transaction
router = APIRouter()
@@ -321,14 +323,15 @@ async def create_customer(
)
customer = Rolodex(**customer_data.model_dump())
db.add(customer)
db.commit()
db.refresh(customer)
with db_transaction(db) as session:
session.add(customer)
session.flush()
session.refresh(customer)
try:
await invalidate_search_cache()
except Exception:
pass
except Exception as e:
app_logger.warning(f"Failed to invalidate search cache: {str(e)}")
return customer
@@ -352,12 +355,13 @@ async def update_customer(
for field, value in customer_data.model_dump(exclude_unset=True).items():
setattr(customer, field, value)
db.commit()
db.refresh(customer)
with db_transaction(db) as session:
session.flush()
session.refresh(customer)
try:
await invalidate_search_cache()
except Exception:
pass
except Exception as e:
app_logger.warning(f"Failed to invalidate search cache: {str(e)}")
return customer
@@ -376,12 +380,12 @@ async def delete_customer(
detail="Customer not found"
)
db.delete(customer)
db.commit()
with db_transaction(db) as session:
session.delete(customer)
try:
await invalidate_search_cache()
except Exception:
pass
except Exception as e:
app_logger.warning(f"Failed to invalidate search cache: {str(e)}")
return {"message": "Customer deleted successfully"}