Skip to content

add endpoints for acme energy consumption - #299

Merged
tekwani merged 6 commits into
tetherto:developfrom
shrutesh-tether:feat/hourly-consumption
Oct 13, 2026
Merged

tekwani merged 6 commits into
tetherto:developfrom
shrutesh-tether:feat/hourly-consumption

Conversation

@shrutesh-tether

@shrutesh-tether shrutesh-tether commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

@shrutesh-tether
shrutesh-tether marked this pull request as ready for review October 8, 2026 07:19
(req) => ['energy-consumption', req.query.start, req.query.end],
ENDPOINTS.ENERGY_CONSUMPTION,
getEnergyConsumption,
[AUTH_PERMISSIONS.ELECTRICITY]

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.

please use AUTH_PERMISSIONS.POWERMETER

method: HTTP_METHODS.POST,
url: ENDPOINTS.ENERGY_CONSUMPTION,
preValidation: rejectTimezone(),
...createAuthRoute(ctx, saveEnergyConsumption, [AUTH_PERMISSIONS.ELECTRICITY]),

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.

please use AUTH_PERMISSIONS.POWERMETER

tekwani
tekwani previously approved these changes Oct 8, 2026
@paragmore

Copy link
Copy Markdown
Contributor

Cross-checked this against the ACME spec and the FE plan while building the hashrate side (#301). Three things worth deciding before this merges:

  1. POST requires all four MWh fields and replaces the whole hour. Operators only type the total — the CDU/rectifier values only exist after a CSV import. So confirming a manual value on an already-imported hour forces the FE to read the row first and echo the three component values back, or they get zeroed. If the component fields were optional and absent ones kept their stored values, manual confirm stays a single write and imports can't be wiped by accident.

  2. Since there's no delete, clearing a wrong entry means writing zeros — but a zero is a real reading (Phase 1 = site PM − 0), while a missing hour gets flagged as missing. If an operator fat-fingers an hour there's no way back to the 'missing' state. A delete (or treating an all-zero row as absent) would keep that distinction.

  3. Rows only carry updatedAt. The input page mock shows who entered a value and whether it came from typing or the CSV — that needs source + updatedBy stored per row, and we can't backfill them later. updatedBy is available from req._info.user.metadata.email at the route.

@shrutesh-tether

Copy link
Copy Markdown
Contributor Author

POST requires all four MWh fields and replaces the whole hour. Operators only type the total — the CDU/rectifier values only exist after a CSV import. So confirming a manual value on an already-imported hour forces the FE to read the row first and echo the three component values back, or they get zeroed. If the component fields were optional and absent ones kept their stored values, manual confirm stays a single write and imports can't be wiped by accident.

Since the CSV parsing is handled by the FE, it is expected to fetch the 3 component values first and then respond with the updated manual entry. Also the fetch is needed anyway to determine if the value should be overwritten as per this agreed upon logic:

If the CSV has fewer than 12 readings and the hour already has a value, we keep the stored value.

Rows only carry updatedAt. The input page mock shows who entered a value and whether it came from typing or the CSV — that needs source + updatedBy stored per row, and we can't backfill them later. updatedBy is available from req._info.user.metadata.email at the route.

There is no updatedBy in the figma:
Screenshot 2026-10-10 at 9 10 38 AM

paragmore
paragmore previously approved these changes Oct 12, 2026
@shrutesh-tether
shrutesh-tether marked this pull request as draft October 12, 2026 09:59
@shrutesh-tether
shrutesh-tether marked this pull request as ready for review October 13, 2026 04:12
@tekwani
tekwani merged commit dfecdb0 into tetherto:develop Oct 13, 2026
8 checks passed
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