fix: additional code quality and performance improvements
Code quality: - Remove empty except blocks with proper logging - Create shared pagination utility function - Remove duplicate UUID validation code - Fix dead code in translation.py Performance: - Fix N+1 query in followup engine (use join instead of loop) - Add eager loading for customer health scores - Create database indexes for common query patterns: - customers: (user_id, status), (user_id, last_contact_at) - payment_transactions: (user_id, created_at) - followup_logs: (user_id, customer_id) - notifications: (user_id, is_read) Configuration: - Centralize magic numbers in config.py: - Payment prices - File upload limits - Rate limiting settings - Pagination defaults - Update auth.py to use centralized rate limiting config - Update customer/product imports to use centralized upload limits - Update import_service.py to use centralized MAX_ROWS
This commit is contained in:
@@ -84,5 +84,23 @@ class Settings(BaseSettings):
|
||||
PRO_MAX_PRODUCTS: int = 20
|
||||
PRO_DAILY_QUOTATIONS: int = 30
|
||||
|
||||
# Payment prices
|
||||
PRO_MONTHLY_PRICE: int = 99
|
||||
PRO_YEARLY_PRICE: int = 999
|
||||
ENTERPRISE_MONTHLY_PRICE: int = 399
|
||||
ENTERPRISE_YEARLY_PRICE: int = 3999
|
||||
|
||||
# File upload limits
|
||||
MAX_UPLOAD_SIZE: int = 10 * 1024 * 1024 # 10MB
|
||||
MAX_EXCEL_ROWS: int = 10000
|
||||
|
||||
# Rate limiting
|
||||
GUEST_LOGIN_LIMIT: int = 5
|
||||
GUEST_LOGIN_WINDOW: int = 900 # 15 minutes
|
||||
|
||||
# Pagination defaults
|
||||
DEFAULT_PAGE_SIZE: int = 20
|
||||
MAX_PAGE_SIZE: int = 100
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user