use SANDBOX_RECORDS_CLEAN_GRACEFUL_PERIOD env

This commit is contained in:
hjlarry 2025-12-17 14:46:56 +08:00
parent 208a81d224
commit a80194fe06
3 changed files with 18 additions and 9 deletions

View File

@ -647,13 +647,6 @@ class BillingConfig(BaseSettings):
default=False,
)
BILLING_FREE_PLAN_GRACE_PERIOD_DAYS: NonNegativeInt = Field(
description=(
"Extra grace period in days applied after a tenant leaves a paid plan before being treated as free."
),
default=21,
)
class UpdateConfig(BaseSettings):
"""
@ -1159,6 +1152,17 @@ class CeleryScheduleTasksConfig(BaseSettings):
)
class SandboxRecordsCleanConfig(BaseSettings):
SANDBOX_RECORDS_CLEAN_GRACEFUL_PERIOD: NonNegativeInt = Field(
description="Graceful period in days for sandbox records clean after subscription expiration",
default=21,
)
SANDBOX_RECORDS_CLEAN_BATCH_SIZE: PositiveInt = Field(
description="Maximum number of records to process in each batch",
default=1000,
)
class PositionConfig(BaseSettings):
POSITION_PROVIDER_PINS: str = Field(
description="Comma-separated list of pinned model providers",
@ -1306,6 +1310,7 @@ class FeatureConfig(
PositionConfig,
RagEtlConfig,
RepositoryConfig,
SandboxRecordsCleanConfig,
SecurityConfig,
TenantIsolatedTaskQueueConfig,
ToolConfig,

View File

@ -45,7 +45,7 @@ class WorkflowRunCleanup:
self.batch_size = batch_size
self.billing_cache: dict[str, TenantPlanInfo | None] = {}
self.dry_run = dry_run
self.free_plan_grace_period_days = dify_config.BILLING_FREE_PLAN_GRACE_PERIOD_DAYS
self.free_plan_grace_period_days = dify_config.SANDBOX_RECORDS_CLEAN_GRACEFUL_PERIOD
self.workflow_run_repo: APIWorkflowRunRepository
if workflow_run_repo:
self.workflow_run_repo = workflow_run_repo

View File

@ -74,7 +74,11 @@ def create_cleanup(
grace_period_days: int = 0,
**kwargs: Any,
) -> WorkflowRunCleanup:
monkeypatch.setattr(cleanup_module.dify_config, "BILLING_FREE_PLAN_GRACE_PERIOD_DAYS", grace_period_days)
monkeypatch.setattr(
cleanup_module.dify_config,
"SANDBOX_RECORDS_CLEAN_GRACEFUL_PERIOD",
grace_period_days,
)
return WorkflowRunCleanup(workflow_run_repo=repo, **kwargs)