Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
381 changes: 229 additions & 152 deletions frontend/src/App.tsx

Large diffs are not rendered by default.

176 changes: 142 additions & 34 deletions frontend/src/components/DonorDirectoryPage.tsx

Large diffs are not rendered by default.

427 changes: 380 additions & 47 deletions frontend/src/components/OverviewDashboard.tsx

Large diffs are not rendered by default.

123 changes: 108 additions & 15 deletions frontend/src/index.css

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions src/bff/charity.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,23 @@ def parse_iso(value: Optional[str], field: str) -> Optional[str]:
raise HTTPException(status_code=400, detail=str(exc)) from exc


@router.get("/grants/overview/entity-suggestions", response_model=Dict[str, Any])
async def get_grant_entity_suggestions(
sources: Optional[str] = Query(default=None, max_length=500),
limit: int = Query(default=2_500, ge=1, le=5_000),
repo: CharityRepository = Depends(get_charity_repository),
):
"""Return a source-scoped cache of observed donor and recipient names.

The browser filters this response locally as the user types. No Overview
aggregation is refreshed until the user explicitly applies their draft.
"""
return await repo.get_grant_entity_suggestions(
sources=_split_grant_filter(sources) if sources is not None else None,
limit=limit,
)


@router.get("/grants/overview/trends", response_model=GrantTrendsResponse)
async def get_filtered_grant_overview_trends(
currency: Optional[str] = Query(default=None, min_length=3, max_length=4),
Expand Down Expand Up @@ -295,6 +312,42 @@ def parse_iso(value: Optional[str], field: str) -> Optional[str]:
raise HTTPException(status_code=400, detail=str(exc)) from exc


@router.get("/grants/overview/drilldown", response_model=Dict[str, Any])
async def get_grant_overview_drilldown(
selection_type: str = Query(..., pattern="^(period|programme_area)$"),
selection_value: str = Query(..., min_length=1, max_length=160),
currency: Optional[str] = Query(default=None, min_length=3, max_length=4),
date_from: Optional[str] = Query(default=None, max_length=10),
date_to: Optional[str] = Query(default=None, max_length=10),
beneficiary_geographies: Optional[str] = Query(default=None, max_length=500),
programme_areas: Optional[str] = Query(default=None, max_length=1000),
donor: Optional[str] = Query(default=None, max_length=160),
recipient: Optional[str] = Query(default=None, max_length=160),
sources: Optional[str] = Query(default=None, max_length=500),
repo: CharityRepository = Depends(get_charity_repository),
):
"""Return a bounded funder, recipient, and grant slice for one chart value."""
parsed_from = _parse_grant_date(date_from, "date_from")
parsed_to = _parse_grant_date(date_to, "date_to")
if parsed_from and parsed_to and parsed_from > parsed_to:
raise HTTPException(status_code=400, detail="date_from cannot be after date_to")
try:
return await repo.get_grant_overview_drilldown(
selection_type=selection_type,
selection_value=selection_value,
currency=currency,
date_from=parsed_from,
date_to=parsed_to,
beneficiary_geographies=_split_grant_filter(beneficiary_geographies),
programme_areas=_split_grant_filter(programme_areas),
donor=donor,
recipient=recipient,
sources=_split_grant_filter(sources) if sources is not None else None,
)
except ValueError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc


def _parse_grant_date(value: Optional[str], field: str) -> Optional[str]:
if value is None or not value.strip():
return None
Expand Down
Loading
Loading