Документация

Legacy/function inventory cleanup – 2026-05-18

Scope

Цель прохода: найти функции и контракты, которые могли потеряться в ходе эволюции Crisis-Monitor, и убрать только доказанно неиспользуемое наследие.

Runtime facts

  • Production entrypoint remains wsgi:app via Gunicorn in docker-compose.prod.yml.
  • wsgi:app points to the Flask app from app.create_app().
  • app/main.py contains the FastAPI migration layer, but production does not run it as the primary app today.
  • Flask route inventory from create_app(TESTING=True): 335 routes.
  • Template static pass: no orphan HTML templates found; 404.html and 500.html are referenced dynamically by the error handler.

Recovered / reconnected

  • utils.postmortem_report.generate_postmortem_report was referenced by tests and docs but the module was absent. The implementation existed in utils.report_utils; restored a compatibility wrapper that accepts a ticket id.
  • app.services.media_integration.search_archive_photos existed but was not used. /api/media/search now calls it instead of duplicating QazLake search logic in Flask/FastAPI routers.

Removed as proven dead

  • Legacy SQLAlchemy models InformationPlan and InformationPlanConfiguration in app/models/misc.py. Current code uses InformationResponsePlan; no migrations reference the old information_plan or information_plan_configuration tables.
  • Unreferenced helper utils.analytics.top_types.
  • Unreferenced report helpers utils.report_utils.get_report_data and utils.report_utils.get_sla_compliance_report.
  • Duplicate Telegram helpers services.telegram_bot.notify_ticket_created and notify_ticket_updated. Runtime notification paths are app.telegram_alerts.*, utils.telegram.send_formatted_message, and /api/v1/notify/ticket/{ticket_id}.
  • Stale docs/runtime claims that described the FastAPI app as the production primary entrypoint. Production compose runs wsgi:app; app/main.py remains the migration/development ASGI surface.
  • Stale OpenAPI schema name InformationPlan; the active model and API payload are InformationResponsePlan.
  • Unused Apprise notification wrapper and APPRISE_URLS config surface. The active notification paths are Telegram/API/email-specific services, and Apprise was not referenced by any runtime caller.

Not removed yet

  • app/main.py and app/routers/*: looks stale relative to production, but still useful as the FastAPI migration surface. Removing it would be architectural.
  • skipped Phase 8 router tests: noisy, but they document unfinished FastAPI migration expectations.
  • utils/cap_parser.py: not wired to a runtime route, but it is the only helper for external CAP Atom feed ingestion. Kept and covered with unit tests instead of deleting it as dead code.
  • app.services.media_integration.attach_media_to_ticket: mentioned in the old module docstring but never implemented. Documented as a missing contract rather than adding a guessed attachment workflow.