Skip to main content

Recalculate metrics for a specific transaction

POST 

/transactions/:id/recalculate-metrics

Manually triggers recalculation of aggregated metrics from raw meter values for a transaction.

What Gets Recalculated:

  • Latest Values: latestPower, latestCurrent, latestVoltage (from most recent meter value)
  • Average Values: averagePower, averageCurrent, averageVoltage (mean across all samples)
  • Peak Values: peakPower, peakCurrent, peakVoltage (maximum values observed)
  • Energy Total: energyDelivered (from start/end meter values)

When to Use:

  • After manually correcting or deleting meter values
  • When importing historical telemetry data
  • To fix metric calculation errors
  • After data migration or bulk imports

Process Flow:

  1. Fetches all meter values for the transaction
  2. Calculates latest values from most recent samples
  3. Computes averages across all periodic samples
  4. Finds peak values from all samples
  5. Updates transaction record with new metrics
  6. Returns updated transaction object

Performance Note: Recalculation queries all meter values for the transaction. For sessions with thousands of meter values, this may take several seconds.

Best Practices:

  • Only recalculate when metrics appear incorrect
  • Run during low-traffic periods for large sessions
  • Verify results after recalculation
  • Consider impact on billing systems
warning

This operation only updates derived metrics calculated from meter values. It does not modify raw meter value entries or affect billing/invoicing unless your system recalculates bills based on updated metrics.

info

Metrics are automatically calculated when new meter values arrive from chargers. Manual recalculation is only needed when correcting historical data or fixing calculation errors.

tip

For active sessions, metrics update automatically every 30-60 seconds as new meter values arrive. Only recalculate if you suspect the metrics are incorrect.

Request

Responses

A charging transaction/session