```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
@@ -5,6 +5,7 @@ from app.tasks import lifecycle as _lifecycle # noqa: F401
|
||||
from app.tasks import market as _market # noqa: F401
|
||||
from app.tasks import reports as _reports # noqa: F401
|
||||
from app.tasks import risk as _risk # noqa: F401
|
||||
from app.tasks import subscriptions as _subscriptions # noqa: F401
|
||||
|
||||
|
||||
__all__ = ["celery_app"]
|
||||
|
||||
@@ -9,4 +9,16 @@ celery_app = Celery(
|
||||
broker=settings.redis_url,
|
||||
backend=settings.celery_result_backend_url or settings.redis_url,
|
||||
)
|
||||
celery_app.conf.task_always_eager = settings.task_queue_always_eager
|
||||
celery_app.conf.update(
|
||||
accept_content=["json"],
|
||||
broker_connection_retry_on_startup=True,
|
||||
enable_utc=True,
|
||||
result_serializer="json",
|
||||
task_acks_late=True,
|
||||
task_always_eager=settings.task_queue_always_eager,
|
||||
task_eager_propagates=True,
|
||||
task_reject_on_worker_lost=True,
|
||||
task_serializer="json",
|
||||
timezone="Asia/Shanghai",
|
||||
worker_prefetch_multiplier=1,
|
||||
)
|
||||
|
||||
@@ -11,3 +11,4 @@ TASK_DISPATCH_PENDING_EVENTS = "events.dispatch_pending"
|
||||
TASK_RUN_LIFECYCLE = "reports.run_lifecycle"
|
||||
TASK_RUN_MARKET_REPORT = "market.report.run"
|
||||
TASK_RUN_MARKET_CLOSE = TASK_RUN_MARKET_REPORT
|
||||
TASK_RUN_SUBSCRIPTION_CYCLE = "subscriptions.run_cycle"
|
||||
|
||||
@@ -12,6 +12,7 @@ from app.tasks.constants import (
|
||||
from app.core.constants import ActorValue
|
||||
from app.core.database import SessionLocal
|
||||
from app.modules.feishu.constants import FeishuReceiveIdType
|
||||
from app.modules.reports.constants import ReportPushStatus
|
||||
from app.tasks.app import celery_app
|
||||
|
||||
ReportBuilder = Callable[[Any, str], dict[str, Any]]
|
||||
@@ -96,6 +97,10 @@ def _push_report(
|
||||
db = SessionLocal()
|
||||
try:
|
||||
service = ReportService(db)
|
||||
if push_run_code:
|
||||
push_run = service._get_push_run(push_run_code)
|
||||
if push_run.status == ReportPushStatus.SUCCESS:
|
||||
return dict(push_run.provider_response or {})
|
||||
report = build_report(service, actor)
|
||||
return ReportDeliveryService(db).push_report(
|
||||
report,
|
||||
@@ -104,6 +109,18 @@ def _push_report(
|
||||
actor,
|
||||
push_run_code=push_run_code,
|
||||
)
|
||||
except Exception as exc:
|
||||
if push_run_code:
|
||||
db.rollback()
|
||||
try:
|
||||
ReportService(db).update_push_run(
|
||||
push_run_code,
|
||||
ReportPushStatus.FAILED,
|
||||
error_message=str(exc),
|
||||
)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
11
app/tasks/subscriptions.py
Normal file
11
app/tasks/subscriptions.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from app.application.delivery.subscriptions import run_subscription_cycle
|
||||
from app.core.constants import ActorValue
|
||||
from app.tasks.app import celery_app
|
||||
from app.tasks.constants import TASK_RUN_SUBSCRIPTION_CYCLE
|
||||
|
||||
|
||||
@celery_app.task(name=TASK_RUN_SUBSCRIPTION_CYCLE)
|
||||
def run_subscription_cycle_task(
|
||||
actor: str = ActorValue.SCHEDULER,
|
||||
) -> dict:
|
||||
return run_subscription_cycle(actor=actor)
|
||||
Reference in New Issue
Block a user