mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Scoped codemod over surfsense_backend/app (excluding routes/, Wave E): renames search_space_id -> workspace_id, search_space -> workspace, SearchSpace -> Workspace across services, utils, tasks, agents, gateway, event_bus, notifications, podcasts, automations, observability params, and prompt .md files. Also flips the camelCase payload key searchSpaceId -> workspaceId (no backend reader; hard cutover). Preserved carve-outs (verbatim): Celery task names "delete_search_space_background" and "ai_sort_search_space" (wire names), and the OTel/metric key "search_space.id" (dashboards depend on it). Enum values 'SEARCH_SPACE' and SearchSourceConnector untouched.
27 lines
662 B
Python
27 lines
662 B
Python
"""Object-key construction for stored document files."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import uuid
|
|
|
|
from app.file_storage.persistence.enums import DocumentFileKind
|
|
|
|
|
|
def build_document_file_key(
|
|
*,
|
|
workspace_id: int,
|
|
document_id: int,
|
|
kind: DocumentFileKind,
|
|
filename: str,
|
|
) -> str:
|
|
"""Build the storage key for one document file.
|
|
|
|
Shape: ``documents/{workspace_id}/{document_id}/{kind}/{uuid}{ext}``.
|
|
"""
|
|
extension = os.path.splitext(filename)[1].lower()
|
|
unique = uuid.uuid4().hex
|
|
return (
|
|
f"documents/{workspace_id}/{document_id}/"
|
|
f"{kind.value.lower()}/{unique}{extension}"
|
|
)
|