2026-06-16 02:00:22 +08:00
|
|
|
"""Operations/admin API service functions.
|
2026-05-14 20:01:26 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
This module is a backward-compatible re-export hub. Domain logic lives in
|
|
|
|
|
the `web.services.ops` sub-package:
|
2026-05-14 20:01:26 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
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
|
|
|
|
|
"""
|
2026-06-07 23:05:45 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
from __future__ import annotations
|
2026-05-14 20:01:26 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# 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
|
2026-06-07 22:51:18 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# 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
|
2026-06-07 22:51:18 +08:00
|
|
|
|
|
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
def _require_ops(request):
|
2026-05-14 20:01:26 +08:00
|
|
|
return legacy_routes._require_ops_admin(request)
|
|
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Users / Points / Feedback / Analytics
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2026-06-16 02:03:47 +08:00
|
|
|
from web.services.ops.users import ( # noqa: E402, F401
|
2026-06-16 02:00:22 +08:00
|
|
|
get_ops_analytics_funnel,
|
|
|
|
|
get_ops_weekly_leaderboard,
|
|
|
|
|
grant_ops_feedback_reward,
|
|
|
|
|
grant_ops_points,
|
2026-06-23 17:07:25 +08:00
|
|
|
list_ops_audit_log,
|
2026-06-16 02:00:22 +08:00
|
|
|
list_ops_feedback,
|
|
|
|
|
search_ops_users,
|
|
|
|
|
transfer_ops_points,
|
|
|
|
|
update_ops_feedback_status,
|
|
|
|
|
)
|
2026-05-14 20:01:26 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Payments / Billing / Memberships
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2026-06-16 02:03:47 +08:00
|
|
|
from web.services.ops.payments import ( # noqa: E402, F401
|
2026-06-23 17:07:25 +08:00
|
|
|
create_ops_refund_case,
|
2026-06-16 02:00:22 +08:00
|
|
|
get_ops_billing_risk,
|
|
|
|
|
get_ops_memberships_growth,
|
|
|
|
|
get_ops_memberships_overview,
|
2026-06-23 17:07:25 +08:00
|
|
|
list_ops_refund_cases,
|
2026-06-16 02:00:22 +08:00
|
|
|
list_ops_memberships,
|
|
|
|
|
list_ops_payment_incidents,
|
|
|
|
|
list_ops_payments,
|
|
|
|
|
resolve_ops_payment_incident,
|
2026-06-23 17:07:25 +08:00
|
|
|
update_ops_refund_case,
|
2026-06-16 02:00:22 +08:00
|
|
|
)
|
2026-05-20 17:12:32 +08:00
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Health / Source Health / Training / Truth
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2026-06-16 02:03:47 +08:00
|
|
|
from web.services.ops.health import ( # noqa: E402, F401
|
2026-06-16 02:00:22 +08:00
|
|
|
_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,
|
|
|
|
|
)
|
2026-05-20 17:12:32 +08:00
|
|
|
|
2026-07-03 23:52:03 +08:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Internal market opportunities
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
from web.services.ops.market_opportunities import ( # noqa: E402, F401
|
|
|
|
|
get_ops_market_opportunities,
|
|
|
|
|
)
|
|
|
|
|
|
2026-06-16 02:00:22 +08:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Config / Subscriptions / Logs / Telegram
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2026-06-16 02:03:47 +08:00
|
|
|
from web.services.ops.config import ( # noqa: E402, F401
|
2026-06-16 02:00:22 +08:00
|
|
|
_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,
|
|
|
|
|
)
|