mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
refactor(backend): rename search_space -> workspace across app bulk (Phase 2 Wave D)
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.
This commit is contained in:
parent
0c53d884eb
commit
7fb0707933
259 changed files with 1996 additions and 1996 deletions
|
|
@ -35,7 +35,7 @@ router = APIRouter(prefix="/notifications", tags=["notifications"])
|
|||
|
||||
@router.get("/unread-counts-batch", response_model=BatchUnreadCountResponse)
|
||||
async def get_unread_counts_batch(
|
||||
search_space_id: int | None = Query(None, description="Filter by search space ID"),
|
||||
workspace_id: int | None = Query(None, description="Filter by workspace ID"),
|
||||
auth: AuthContext = Depends(require_session_context),
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
) -> BatchUnreadCountResponse:
|
||||
|
|
@ -48,11 +48,11 @@ async def get_unread_counts_batch(
|
|||
Notification.read == False, # noqa: E712
|
||||
]
|
||||
|
||||
if search_space_id is not None:
|
||||
# Include global (null search-space) notifications.
|
||||
if workspace_id is not None:
|
||||
# Include global (null workspace) notifications.
|
||||
base_filter.append(
|
||||
(Notification.search_space_id == search_space_id)
|
||||
| (Notification.search_space_id.is_(None))
|
||||
(Notification.workspace_id == workspace_id)
|
||||
| (Notification.workspace_id.is_(None))
|
||||
)
|
||||
|
||||
is_comments = Notification.type.in_(CATEGORY_TYPES["comments"])
|
||||
|
|
@ -87,7 +87,7 @@ async def get_unread_counts_batch(
|
|||
|
||||
@router.get("/source-types", response_model=SourceTypesResponse)
|
||||
async def get_notification_source_types(
|
||||
search_space_id: int | None = Query(None, description="Filter by search space ID"),
|
||||
workspace_id: int | None = Query(None, description="Filter by workspace ID"),
|
||||
auth: AuthContext = Depends(require_session_context),
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
) -> SourceTypesResponse:
|
||||
|
|
@ -95,11 +95,11 @@ async def get_notification_source_types(
|
|||
user = auth.user
|
||||
base_filter = [Notification.user_id == user.id]
|
||||
|
||||
if search_space_id is not None:
|
||||
# Include global (null search-space) notifications.
|
||||
if workspace_id is not None:
|
||||
# Include global (null workspace) notifications.
|
||||
base_filter.append(
|
||||
(Notification.search_space_id == search_space_id)
|
||||
| (Notification.search_space_id.is_(None))
|
||||
(Notification.workspace_id == workspace_id)
|
||||
| (Notification.workspace_id.is_(None))
|
||||
)
|
||||
|
||||
connector_type_expr = Notification.notification_metadata["connector_type"].astext
|
||||
|
|
@ -156,7 +156,7 @@ async def get_notification_source_types(
|
|||
|
||||
@router.get("/unread-count", response_model=UnreadCountResponse)
|
||||
async def get_unread_count(
|
||||
search_space_id: int | None = Query(None, description="Filter by search space ID"),
|
||||
workspace_id: int | None = Query(None, description="Filter by workspace ID"),
|
||||
type_filter: NotificationType | None = Query(
|
||||
None, alias="type", description="Filter by notification type"
|
||||
),
|
||||
|
|
@ -179,11 +179,11 @@ async def get_unread_count(
|
|||
Notification.read == False, # noqa: E712
|
||||
]
|
||||
|
||||
if search_space_id is not None:
|
||||
# Include global (null search-space) notifications.
|
||||
if workspace_id is not None:
|
||||
# Include global (null workspace) notifications.
|
||||
base_filter.append(
|
||||
(Notification.search_space_id == search_space_id)
|
||||
| (Notification.search_space_id.is_(None))
|
||||
(Notification.workspace_id == workspace_id)
|
||||
| (Notification.workspace_id.is_(None))
|
||||
)
|
||||
|
||||
if type_filter:
|
||||
|
|
@ -211,7 +211,7 @@ async def get_unread_count(
|
|||
|
||||
@router.get("", response_model=NotificationListResponse)
|
||||
async def list_notifications(
|
||||
search_space_id: int | None = Query(None, description="Filter by search space ID"),
|
||||
workspace_id: int | None = Query(None, description="Filter by workspace ID"),
|
||||
type_filter: NotificationType | None = Query(
|
||||
None, alias="type", description="Filter by notification type"
|
||||
),
|
||||
|
|
@ -244,15 +244,15 @@ async def list_notifications(
|
|||
Notification.user_id == user.id
|
||||
)
|
||||
|
||||
if search_space_id is not None:
|
||||
# Include global (null search-space) notifications.
|
||||
if workspace_id is not None:
|
||||
# Include global (null workspace) notifications.
|
||||
query = query.where(
|
||||
(Notification.search_space_id == search_space_id)
|
||||
| (Notification.search_space_id.is_(None))
|
||||
(Notification.workspace_id == workspace_id)
|
||||
| (Notification.workspace_id.is_(None))
|
||||
)
|
||||
count_query = count_query.where(
|
||||
(Notification.search_space_id == search_space_id)
|
||||
| (Notification.search_space_id.is_(None))
|
||||
(Notification.workspace_id == workspace_id)
|
||||
| (Notification.workspace_id.is_(None))
|
||||
)
|
||||
|
||||
if type_filter:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class NotificationResponse(BaseModel):
|
|||
|
||||
id: int
|
||||
user_id: str
|
||||
search_space_id: int | None
|
||||
workspace_id: int | None
|
||||
type: str
|
||||
title: str
|
||||
message: str
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ def to_response(notification: Notification) -> NotificationResponse:
|
|||
return NotificationResponse(
|
||||
id=notification.id,
|
||||
user_id=str(notification.user_id),
|
||||
search_space_id=notification.search_space_id,
|
||||
workspace_id=notification.workspace_id,
|
||||
type=notification.type,
|
||||
title=notification.title,
|
||||
message=notification.message,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue