Fix: Add PAW computed terms to dataContract for v3 API streaming
Resolved 💬 2 comments Opened Oct 13, 2025 by chooglygit Closed Nov 29, 2025
Problem
Hero card was displaying -- for PAW metrics despite data existing in the database.
Root Cause: PAW computed terms were not included in the template's dataContract, so TemplateDataEngine.getTimeSeriesDataForTemplate() filtered them out when querying observations.
Solution
Added 4 PAW computed terms to sugarcane-standard template's dataContract.optional:
SOIL.PAW_PERCENT_ENHANCED- Plant Available Water percentageSOIL.PAW_AVAILABLE_MM- Available water in millimetersCONFIG.KC_NDVI_ADJUSTED- NDVI-adjusted crop coefficientCROP.IRRIGATION_TRIGGER_SM- Irrigation trigger soil moisture threshold
Changes
Database:
- Template version: 53.1 → 53.2
- Updated
industry_templates.data_contractto include PAW terms - Created version snapshots:
53.1-pre-paw-datacontractand53.2-post-paw-datacontract
Impact:
- TemplateDataEngine now queries PAW computed terms from observations_universal
- v3 intelligence API streams PAW data in
soilandconfignamespaces - Hero card can now display PAW metrics correctly
Technical Details
File: apps/sensor-processor/src/intelligence/services/template-data-engine.service.ts
- Query at lines 83-89 uses
data_contractterms to filter observations - Without PAW terms in dataContract, they were excluded from API response
Query Logic:
const terms = [
...(template.dataContract?.required?.map(r => r.term) || []),
...(template.dataContract?.optional?.map(r => r.term) || [])
];
Related
- Issue #509 - PAW metrics implementation (Phase 2 backend, Phase 2.5 hero card)
- Template version control system for safe rollback
- v3 intelligence API streaming architecture
Status
✅ Fixed - Template updated and tested in ACA deployment
✅ Hero card now displays PAW metrics correctly
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗