Skip to content

Devsjc/price table - #217

Merged
devsjc merged 4 commits into
mainfrom
devsjc/price-table
Oct 16, 2026
Merged

devsjc merged 4 commits into
mainfrom
devsjc/price-table

Conversation

@devsjc

@devsjc devsjc commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Adds a price table in the observations schema to track price data, and suitable RPCs to fetch/retrieve it!

Contribution Checklist

  • Have you followed the Open Climate Fix Contribution Guidelines?
  • Have you referenced the Issue this PR addresses, where applicable?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added a summary of the changes?
  • Have you written new tests for your changes, where applicable?
  • Have you successfully run make lint with your changes locally?
  • Have you successfully run make test with your changes locally?

Warning

PRs may be closed if all the above boxes are not checked.

Closes #182

Copilot AI 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.

🔵 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_values schema (migration 00018) plus consolidation of the observation created_timestamp_utc column into 00017.
  • New proto messages/RPCs and a valid_market_name validation 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.

Comment thread internal/server/postgres/sql/queries/prices.sql
Comment thread internal/server/postgres/dataserverimpl_test.go Outdated
devsjc and others added 2 commits October 16, 2026 15:31
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@devsjc
devsjc merged commit 1e762c8 into main Oct 16, 2026
4 checks passed
@devsjc
devsjc deleted the devsjc/price-table branch October 16, 2026 15:04
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.

Discuss: Store price data

2 participants