pkmntrade.club/src/pkmntrade_club/common/context_processors.py
badbl0cks af2f48a491
refactor(db): update cursor rules and enhance deployment rollback script
- Standardized string formatting in cursor rules for consistency.
- Added a new rollback deployment script to facilitate blue-green deployment strategy.
- Removed outdated seed data files and introduced new rarity mappings for better data management.
- Improved model relationships and query optimizations in various views and admin configurations.
- Enhanced caching strategies across templates to improve performance and reduce load times, including jitter in cache settings for better performance.
- Refactored card-related views and templates to utilize new model fields and relationships.
2025-06-19 15:42:36 -07:00

28 lines
782 B
Python

import random
from django.conf import settings
def cache_settings(request):
"""
Pass cache settings to the template context.
Applies jitter to the timeouts.
"""
jitter = settings.CACHE_JITTER
return {
"CACHE_SHORT_TIMEOUT": settings.CACHE_SHORT_TIMEOUT
+ random.randint(-jitter, jitter),
"CACHE_MEDIUM_TIMEOUT": settings.CACHE_MEDIUM_TIMEOUT
+ random.randint(-jitter, jitter),
"CACHE_LONG_TIMEOUT": settings.CACHE_LONG_TIMEOUT
+ random.randint(-jitter, jitter),
"CACHE_DEFAULT_TIMEOUT": settings.CACHE_DEFAULT_TIMEOUT
+ random.randint(-jitter, jitter),
}
def version_info(request):
return {
"VERSION": settings.VERSION,
"VERSION_INFO": settings.VERSION_INFO,
}