Repository navigation
Devsjc/price table - #217
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It introduces database schema migrations (including restructuring an existing migration) and new public proto API surface, which warrant final human review.
2 open findings
What changed in this PR
This PR implements storage and retrieval of energy market price data (closing #182). It adds a new obs.markets table and obs.observed_price_values table, together with four new RPCs (CreateMarket, ListMarkets, CreateEnergyPrices, GetEnergyPricesAsTimeseries) and their protovalidate rules, SQL queries, Postgres/dummy implementations, mappers, and tests. Prices are stored as integer hundredths of the market currency per MWh, keyed by market, and support idempotent republishing (unchanged values keep their original created timestamp). It also folds the created_timestamp_utc column into the consolidated schema migration (removing the separate 00017_observation_created_timestamp.sql).
Changes:
- New
obs.markets/obs.observed_price_valuesschema (migration00018) plus consolidation of the observationcreated_timestamp_utccolumn into00017. - New proto messages/RPCs and a
valid_market_namevalidation rule for the price/market API. - Postgres and dummy server implementations, price<->hundredths mappers, SQL queries, and comprehensive tests.
| File | Description |
|---|---|
| proto/ocf/dp/dp.rules.proto | Adds valid_market_name string rule (unique extension field 4457822). |
| proto/ocf/dp/dp-data.service.proto | Declares the 4 new market/price RPCs. |
| proto/ocf/dp/dp-data.messages.proto | Adds request/response messages with validation bounds. |
| internal/server/postgres/sql/queries/prices.sql | CRUD/upsert queries for markets and prices. |
| internal/server/postgres/sql/migrations/00018_price_table.sql | Creates markets and observed_price_values tables. |
| internal/server/postgres/sql/migrations/00017_consolidated_schema.sql | Bakes created_timestamp_utc into the generation values table. |
| internal/server/postgres/sql/migrations/00017_observation_created_timestamp.sql | Removes the now-consolidated migration. |
| internal/server/postgres/mappers.go | Price<->hundredths conversion and market/price mappers. |
| internal/server/postgres/dataserverimpl.go | Postgres implementation of the 4 RPCs. |
| internal/server/dummy/dataserverimpl.go | Dummy implementation returning synthetic data. |
| internal/server/postgres/mappers_test.go | Unit tests for conversion/mapping. |
| internal/server/postgres/dataserverimpl_test.go | Integration tests for markets/prices RPCs. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>


Adds a price table in the observations schema to track price data, and suitable RPCs to fetch/retrieve it!
Contribution Checklist
make lintwith your changes locally?make testwith your changes locally?Warning
PRs may be closed if all the above boxes are not checked.
Closes #182