flip_api.project_services.get_projects
Attributes
Functions
Fetches paginated project data from the database using SQLModel ORM. |
|
|
Batch-load most-recent cohort query + cohort size for each project. |
|
Batch-load the most recent |
|
Per-project user count. |
|
Get a paginated and filtered list of projects. |
Module Contents
- flip_api.project_services.get_projects.router
- flip_api.project_services.get_projects.get_projects_paginated_orm(session: sqlmodel.Session, user_id: uuid.UUID | None, paging_details: flip_api.utils.paging_utils.PagingInfo, filter_details: flip_api.utils.paging_utils.FilterInfo) flip_api.utils.paging_utils.IPagedResponse[flip_api.domain.interfaces.project.IProject]
Fetches paginated project data from the database using SQLModel ORM.
- Parameters:
session (Session) – The SQLModel session used for the database queries.
user_id (UUID | None) – The requesting user’s ID. When provided, results are restricted to projects the user owns or has explicit access to.
paging_details (PagingInfo) – Page size, offset, and optional search string.
filter_details (FilterInfo) – Additional filter criteria (e.g. owner ID).
- Returns:
Paginated list of projects and total row count.
- Return type:
- flip_api.project_services.get_projects._load_latest_query_per_project(project_ids: list[uuid.UUID], session: sqlmodel.Session) dict[uuid.UUID, flip_api.domain.interfaces.project.IProjectQuery]
Batch-load most-recent cohort query + cohort size for each project.
Avoids the N+1 cost of calling the per-project query loader on every row. Three queries total: pick the latest Queries row per project, then batch the trust counts and the cohort totals for the picked query IDs.
- Parameters:
project_ids – Project IDs to load queries for.
session – Active SQLModel session.
- Returns:
Mapping project_id →
IProjectQueryfor projects that have at least one cohort query. Projects without one are omitted from the result.
- flip_api.project_services.get_projects._load_latest_audit_at_per_project(project_ids: list[uuid.UUID], action: flip_api.domain.schemas.actions.ProjectAuditAction, session: sqlmodel.Session) dict[uuid.UUID, str]
Batch-load the most recent
projects_audittimestamp per project for a given action.One SQL round-trip — useful for surfacing stage transition dates (STAGE, APPROVE, UNSTAGE, etc.) without paying the N+1 cost of per-project audit lookups.
- flip_api.project_services.get_projects._load_user_counts(project_ids: list[uuid.UUID], session: sqlmodel.Session) dict[uuid.UUID, int]
Per-project user count.
The owner is auto-added to
ProjectUserAccesson project creation, so this count includes them and the UI doesn’t need to+1.
- flip_api.project_services.get_projects.get_projects_endpoint(request: fastapi.Request, session: sqlmodel.Session = Depends(get_session), user_id: uuid.UUID = Depends(verify_token)) flip_api.utils.paging_utils.IPagedData[flip_api.domain.interfaces.project.IProject]
Get a paginated and filtered list of projects.
- Parameters:
request (Request) – The HTTP request object, used to access query parameters.
session (Session) – The database session for querying.
user_id (UUID) – The ID of the user making the request.
- Returns:
A paginated response containing the projects.
- Return type:
- Raises:
HTTPException – If an error occurs while fetching projects.