Defer constance config reads in Season.generate_default to avoid DB access at import time
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,13 @@ class Season(RulesModel):
|
|||||||
return season
|
return season
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_default(cls, day: int = config.TF_DEFAULT_SEASON_DAY, month: int = config.TF_DEFAULT_SEASON_MONTH, duration: str = config.TF_DEFAULT_SEASON_DURATION) -> "Season":
|
def generate_default(cls, day: int | None = None, month: int | None = None, duration: str | None = None) -> "Season":
|
||||||
|
if day is None:
|
||||||
|
day = config.TF_DEFAULT_SEASON_DAY
|
||||||
|
if month is None:
|
||||||
|
month = config.TF_DEFAULT_SEASON_MONTH
|
||||||
|
if duration is None:
|
||||||
|
duration = config.TF_DEFAULT_SEASON_DURATION
|
||||||
current_year = timezone.now().date().year
|
current_year = timezone.now().date().year
|
||||||
start_date = datetime.date(current_year, month, day)
|
start_date = datetime.date(current_year, month, day)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user