[split-required] Split 700-870 LOC files across all services
backend-lehrer (11 files): - llm_gateway/routes/schools.py (867 → 5), recording_api.py (848 → 6) - messenger_api.py (840 → 5), print_generator.py (824 → 5) - unit_analytics_api.py (751 → 5), classroom/routes/context.py (726 → 4) - llm_gateway/routes/edu_search_seeds.py (710 → 4) klausur-service (12 files): - ocr_labeling_api.py (845 → 4), metrics_db.py (833 → 4) - legal_corpus_api.py (790 → 4), page_crop.py (758 → 3) - mail/ai_service.py (747 → 4), github_crawler.py (767 → 3) - trocr_service.py (730 → 4), full_compliance_pipeline.py (723 → 4) - dsfa_rag_api.py (715 → 4), ocr_pipeline_auto.py (705 → 4) website (6 pages): - audit-checklist (867 → 8), content (806 → 6) - screen-flow (790 → 4), scraper (789 → 5) - zeugnisse (776 → 5), modules (745 → 4) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
57
backend-lehrer/recording_helpers.py
Normal file
57
backend-lehrer/recording_helpers.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Recording API - In-Memory Storage & Helpers.
|
||||
|
||||
Shared state and utility functions for recording endpoints.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
|
||||
# ==========================================
|
||||
# IN-MEMORY STORAGE (Dev Mode)
|
||||
# ==========================================
|
||||
# In production, these would be database queries
|
||||
|
||||
_recordings_store: dict = {}
|
||||
_transcriptions_store: dict = {}
|
||||
_audit_log: list = []
|
||||
_minutes_store: dict = {}
|
||||
|
||||
|
||||
def log_audit(
|
||||
action: str,
|
||||
recording_id: Optional[str] = None,
|
||||
transcription_id: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
metadata: Optional[dict] = None
|
||||
):
|
||||
"""Log audit event for DSGVO compliance."""
|
||||
_audit_log.append({
|
||||
"id": str(uuid.uuid4()),
|
||||
"recording_id": recording_id,
|
||||
"transcription_id": transcription_id,
|
||||
"user_id": user_id,
|
||||
"action": action,
|
||||
"metadata": metadata or {},
|
||||
"created_at": datetime.utcnow().isoformat()
|
||||
})
|
||||
|
||||
|
||||
def format_vtt_time(ms: int) -> str:
|
||||
"""Format milliseconds to VTT timestamp (HH:MM:SS.mmm)."""
|
||||
hours = ms // 3600000
|
||||
minutes = (ms % 3600000) // 60000
|
||||
seconds = (ms % 60000) // 1000
|
||||
millis = ms % 1000
|
||||
return f"{hours:02d}:{minutes:02d}:{seconds:02d}.{millis:03d}"
|
||||
|
||||
|
||||
def format_srt_time(ms: int) -> str:
|
||||
"""Format milliseconds to SRT timestamp (HH:MM:SS,mmm)."""
|
||||
hours = ms // 3600000
|
||||
minutes = (ms % 3600000) // 60000
|
||||
seconds = (ms % 60000) // 1000
|
||||
millis = ms % 1000
|
||||
return f"{hours:02d}:{minutes:02d}:{seconds:02d},{millis:03d}"
|
||||
Reference in New Issue
Block a user