Skip to content

fix: restrict organisation ID filtering to SITE/SUBSTATION location types in Data Platform client#333

Open
PavanRaghavendraKulkarni wants to merge 10 commits into
mainfrom
fix/restrict-org-id-filtering
Open

fix: restrict organisation ID filtering to SITE/SUBSTATION location types in Data Platform client#333
PavanRaghavendraKulkarni wants to merge 10 commits into
mainfrom
fix/restrict-org-id-filtering

Conversation

@PavanRaghavendraKulkarni

@PavanRaghavendraKulkarni PavanRaghavendraKulkarni commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the Data Platform client so that organisation ID filtering is only applied to SITE and SUBSTATION location types, not to regional or national queries.

Motivation

Prior to this change, the organisation ID filter was applied to all location types when an auth token was present. This inadvertently blocked Adani site forecast and generation queries because the org filter was also being applied inside get_predicted_generation and get_actual_generation for non-site location types.

Changes

src/quartz_api/internal/backends/dataplatform/client.py

  • get_predicted_generation: org ID filter now only applied when location_type is SITE or SUBSTATION
  • get_actual_generation: _check_user_access now only called for SITE location type
  • put_actual_generation: _check_user_access now only called for SITE location type

Testing

Manually verified against local dev environment with a valid auth token:

Endpoint
GET /sites
GET /sites/{uuid}/forecast (org site)
GET /sites/{uuid}/generation (org site)
GET /sites/{uuid}/forecast (other site)

@PavanRaghavendraKulkarni PavanRaghavendraKulkarni marked this pull request as ready for review June 25, 2026 06:50
Comment thread src/quartz_api/internal/service/regions/router.py Outdated

@peterdudfield peterdudfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure the title of this PR is correct

@PavanRaghavendraKulkarni PavanRaghavendraKulkarni changed the title Fix/restrict org id filtering fix: restrict organisation ID filtering to SITE/SUBSTATION location types in Data Platform client Jun 29, 2026
organisation_id: str | None = get_org_id_from_authdata(authdata) if authdata != {} else None
_site_level = location_type in (
models.LocationType.SITE,
models.LocationType.SUBSTATION,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove substation?

@peterdudfield

Copy link
Copy Markdown
Contributor

Im not sure this is needed. For Adani there are only sites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants