dca4f2d618
- web/core.py 858→236行,拆出 schemas/middleware/auth/diagnostics - ops_api.py 2876→4个 domain 模块 (users/payments/health/config) - DBManager Supabase HTTP 调用提取到 SupabaseAdminClient - 新增 LockedSQLiteConnection 统一多进程读写锁 - 新增 WeatherCacheManager 替代 12 个独立缓存字典 - METAR 缓存迁移至统一缓存管理器 - analysis_service 提取 _build_intraday_meteorology 到独立模块 - DEB 改进:偏差惩罚、分歧回退、自适应 lookback (MAE ↓12.6%) - 新增 PyTorch 注意力模型 deb_attention.py (数据积累后启用) - 新增 torch 到 requirements.lock
85 lines
3.1 KiB
Python
85 lines
3.1 KiB
Python
"""Operations/admin API service functions.
|
|
|
|
This module is a backward-compatible re-export hub. Domain logic lives in
|
|
the `web.services.ops` sub-package:
|
|
|
|
ops/users.py — users, points, feedback, analytics, leaderboard
|
|
ops/payments.py — payment incidents, billing risk, memberships
|
|
ops/health.py — health check, source health, training accuracy, truth
|
|
ops/config.py — config, subscriptions, logs, telegram audit
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
# Backward-compat: tests monkeypatch ops_api._requests, ops_api.legacy_routes,
|
|
# ops_api.DBManager and other module-level symbols.
|
|
import requests as _requests # noqa: F401
|
|
import web.routes as legacy_routes # noqa: F401
|
|
from src.database.db_manager import DBManager # noqa: F401
|
|
from src.database.runtime_state import ObservationCollectorStatusRepository # noqa: F401
|
|
|
|
# Backward-compat: internal helpers referenced by tests
|
|
from web.services.ops.config import _lookup_supabase_user_id_by_email # noqa: F401
|
|
from web.services.ops.health import _check_amsc_awos_health # noqa: F401
|
|
from web.services.ops.payments import _list_active_subscriptions_with_windows # noqa: F401
|
|
|
|
|
|
def _require_ops(request):
|
|
return legacy_routes._require_ops_admin(request)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Users / Points / Feedback / Analytics
|
|
# ---------------------------------------------------------------------------
|
|
from web.services.ops.users import ( # noqa: F401
|
|
get_ops_analytics_funnel,
|
|
get_ops_weekly_leaderboard,
|
|
grant_ops_feedback_reward,
|
|
grant_ops_points,
|
|
list_ops_feedback,
|
|
search_ops_users,
|
|
transfer_ops_points,
|
|
update_ops_feedback_status,
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Payments / Billing / Memberships
|
|
# ---------------------------------------------------------------------------
|
|
from web.services.ops.payments import ( # noqa: F401
|
|
get_ops_billing_risk,
|
|
get_ops_memberships_growth,
|
|
get_ops_memberships_overview,
|
|
list_ops_memberships,
|
|
list_ops_payment_incidents,
|
|
list_ops_payments,
|
|
resolve_ops_payment_incident,
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Health / Source Health / Training / Truth
|
|
# ---------------------------------------------------------------------------
|
|
from web.services.ops.health import ( # noqa: F401
|
|
_build_training_accuracy_payload,
|
|
get_ops_health_check,
|
|
get_ops_observation_collector_status,
|
|
get_ops_source_health,
|
|
get_ops_training_accuracy,
|
|
get_ops_truth_history,
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Config / Subscriptions / Logs / Telegram
|
|
# ---------------------------------------------------------------------------
|
|
from web.services.ops.config import ( # noqa: F401
|
|
_lookup_supabase_user_id_by_email,
|
|
_supabase_rest_rows,
|
|
extend_ops_subscription,
|
|
get_ops_config,
|
|
get_ops_logs,
|
|
get_ops_sensitive_config,
|
|
get_ops_telegram_audit,
|
|
get_ops_user_subscriptions,
|
|
grant_ops_subscription,
|
|
update_ops_config,
|
|
update_ops_sensitive_config,
|
|
)
|