Skip to content

Commit

Permalink
Merge pull request #5077 from ebmdatalab/evansd/fix-spending-api
Browse files Browse the repository at this point in the history
Fix logic for selecting practices by SICBL
  • Loading branch information
evansd authored Nov 27, 2024
2 parents c3cd89e + f03f43d commit b18c9ab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openprescribing/api/views_spending.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,10 @@ def spending_by_org(request, format=None, org_type=None):

def _get_org_type_and_orgs(org_type, org_ids):
org_type = utils.translate_org_type(org_type)
select_all_orgs = not org_ids

# If no org parameters are supplied then we sum over absolutely everything
if org_type is None and not org_ids:
if org_type is None and select_all_orgs:
return "all_practices", [AllEngland()]

# Some special case handling for practices
Expand Down Expand Up @@ -397,7 +398,7 @@ def _get_org_type_and_orgs(org_type, org_ids):
raise ValidationError(detail="Error: unrecognised org_type parameter")

# Filter and sort
if org_ids:
if not select_all_orgs:
orgs = orgs.filter(code__in=org_ids)
orgs = orgs.order_by("code")

Expand Down

0 comments on commit b18c9ab

Please sign in to comment.