Skip to content

Feat: add GET /auth/finance/cost-summary endpoint#6

Closed
mukama wants to merge 3 commits intotetherto:developfrom
mukama:feat/finance-cost-summary
Closed

Feat: add GET /auth/finance/cost-summary endpoint#6
mukama wants to merge 3 commits intotetherto:developfrom
mukama:feat/finance-cost-summary

Conversation

@mukama
Copy link
Contributor

@mukama mukama commented Feb 12, 2026

Summary

  • Add GET /auth/finance/cost-summary endpoint with energy and operational cost breakdowns
  • Support period param for daily/monthly/yearly aggregation
  • Support site param for site-specific production costs
  • Fixed cost processing to handle globalDataLib flat object format

Example Queries

Monthly (default):

/auth/finance/cost-summary?start=1735689600000&end=1770898000000

Daily:

/auth/finance/cost-summary?start=1735689600000&end=1770898000000&period=daily

Add cost summary API endpoint that aggregates production costs, BTC
prices, and power consumption to calculate energy and operational cost
breakdowns with period-based aggregation.
- Fix processCostsData to handle flat objects from globalDataLib with daily costs
- Replace direct globalDataLib range query with getProductionCosts helper
- Add site query param to schema, cache key, and handler for site-specific costs
- Update tests to match new cost format
@mukama mukama changed the base branch from main to develop February 13, 2026 10:21
const { testModuleStructure, testHandlerFunctions, testOnRequestFunctions } = require('../helpers/routeTestHelpers')
const { createRoutesForTest } = require('../helpers/mockHelpers')

const ROUTES_PATH = '../../../workers/lib/server/routes/finance.routes.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

include in integration test as well

start: { type: 'integer' },
end: { type: 'integer' },
period: { type: 'string', enum: ['daily', 'monthly', 'yearly'] },
site: { type: 'string' },
Copy link
Contributor

Choose a reason for hiding this comment

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

site param is not needed as data is being fetched for a single site.

… test

Data is fetched for a single site, so the site parameter is unnecessary.
Added security integration test for finance/cost-summary endpoint.
@mukama
Copy link
Contributor Author

mukama commented Feb 15, 2026

Moved to #11

@mukama mukama closed this Feb 15, 2026
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.

2 participants