mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 19:16:03 +08:00
feat: add command to clear free plan tenant expired data
This commit is contained in:
parent
e61415223b
commit
8e152a83bf
@ -26,6 +26,7 @@ from models.dataset import Document as DatasetDocument
|
|||||||
from models.model import Account, App, AppAnnotationSetting, AppMode, Conversation, MessageAnnotation
|
from models.model import Account, App, AppAnnotationSetting, AppMode, Conversation, MessageAnnotation
|
||||||
from models.provider import Provider, ProviderModel
|
from models.provider import Provider, ProviderModel
|
||||||
from services.account_service import RegisterService, TenantService
|
from services.account_service import RegisterService, TenantService
|
||||||
|
from services.clear_free_plan_tenant_expired_logs import ClearFreePlanTenantExpiredLogs
|
||||||
from services.plugin.data_migration import PluginDataMigration
|
from services.plugin.data_migration import PluginDataMigration
|
||||||
from services.plugin.plugin_migration import PluginMigration
|
from services.plugin.plugin_migration import PluginMigration
|
||||||
|
|
||||||
@ -792,3 +793,23 @@ def install_plugins(input_file: str, output_file: str, workers: int):
|
|||||||
PluginMigration.install_plugins(input_file, output_file, workers)
|
PluginMigration.install_plugins(input_file, output_file, workers)
|
||||||
|
|
||||||
click.echo(click.style("Install plugins completed.", fg="green"))
|
click.echo(click.style("Install plugins completed.", fg="green"))
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("clear-free-plan-tenant-expired-logs", help="Clear free plan tenant expired logs.")
|
||||||
|
@click.option("--days", prompt=True, help="The days to clear free plan tenant expired logs.", default=30)
|
||||||
|
@click.option("--batch", prompt=True, help="The batch size to clear free plan tenant expired logs.", default=100)
|
||||||
|
@click.option(
|
||||||
|
"--tenant_ids",
|
||||||
|
prompt=True,
|
||||||
|
multiple=True,
|
||||||
|
help="The tenant ids to clear free plan tenant expired logs.",
|
||||||
|
)
|
||||||
|
def clear_free_plan_tenant_expired_logs(days: int, batch: int, tenant_ids: list[str]):
|
||||||
|
"""
|
||||||
|
Clear free plan tenant expired logs.
|
||||||
|
"""
|
||||||
|
click.echo(click.style("Starting clear free plan tenant expired logs.", fg="white"))
|
||||||
|
|
||||||
|
ClearFreePlanTenantExpiredLogs.process(days, batch, tenant_ids)
|
||||||
|
|
||||||
|
click.echo(click.style("Clear free plan tenant expired logs completed.", fg="green"))
|
||||||
|
@ -4,6 +4,7 @@ from dify_app import DifyApp
|
|||||||
def init_app(app: DifyApp):
|
def init_app(app: DifyApp):
|
||||||
from commands import (
|
from commands import (
|
||||||
add_qdrant_index,
|
add_qdrant_index,
|
||||||
|
clear_free_plan_tenant_expired_logs,
|
||||||
convert_to_agent_apps,
|
convert_to_agent_apps,
|
||||||
create_tenant,
|
create_tenant,
|
||||||
extract_plugins,
|
extract_plugins,
|
||||||
@ -34,6 +35,7 @@ def init_app(app: DifyApp):
|
|||||||
extract_unique_plugins,
|
extract_unique_plugins,
|
||||||
install_plugins,
|
install_plugins,
|
||||||
old_metadata_migration,
|
old_metadata_migration,
|
||||||
|
clear_free_plan_tenant_expired_logs,
|
||||||
]
|
]
|
||||||
for cmd in cmds_to_register:
|
for cmd in cmds_to_register:
|
||||||
app.cli.add_command(cmd)
|
app.cli.add_command(cmd)
|
||||||
|
@ -838,6 +838,33 @@ class Conversation(db.Model): # type: ignore[name-defined]
|
|||||||
def in_debug_mode(self):
|
def in_debug_mode(self):
|
||||||
return self.override_model_configs is not None
|
return self.override_model_configs is not None
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {
|
||||||
|
"id": self.id,
|
||||||
|
"app_id": self.app_id,
|
||||||
|
"app_model_config_id": self.app_model_config_id,
|
||||||
|
"model_provider": self.model_provider,
|
||||||
|
"override_model_configs": self.override_model_configs,
|
||||||
|
"model_id": self.model_id,
|
||||||
|
"mode": self.mode,
|
||||||
|
"name": self.name,
|
||||||
|
"summary": self.summary,
|
||||||
|
"inputs": self.inputs,
|
||||||
|
"introduction": self.introduction,
|
||||||
|
"system_instruction": self.system_instruction,
|
||||||
|
"system_instruction_tokens": self.system_instruction_tokens,
|
||||||
|
"status": self.status,
|
||||||
|
"invoke_from": self.invoke_from,
|
||||||
|
"from_source": self.from_source,
|
||||||
|
"from_end_user_id": self.from_end_user_id,
|
||||||
|
"from_account_id": self.from_account_id,
|
||||||
|
"read_at": self.read_at,
|
||||||
|
"read_account_id": self.read_account_id,
|
||||||
|
"dialogue_count": self.dialogue_count,
|
||||||
|
"created_at": self.created_at,
|
||||||
|
"updated_at": self.updated_at,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Message(db.Model): # type: ignore[name-defined]
|
class Message(db.Model): # type: ignore[name-defined]
|
||||||
__tablename__ = "messages"
|
__tablename__ = "messages"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user