mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-10-27 03:27:56 +00:00
Refactor TotalEnergyConsumptionBloc to use DividedTotalEnergyConsumptionDecorator for adjusted energy values and update chart data handling in TotalEnergyConsumptionChart.
This commit is contained in:
+20
@@ -59,3 +59,23 @@ abstract final class _TotalEnergyConsumptionResponseMapper {
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class DividedTotalEnergyConsumptionDecorator
|
||||
implements TotalEnergyConsumptionService {
|
||||
const DividedTotalEnergyConsumptionDecorator(this._decoratee);
|
||||
|
||||
final TotalEnergyConsumptionService _decoratee;
|
||||
@override
|
||||
Future<List<EnergyDataModel>> load(
|
||||
GetTotalEnergyConsumptionParam param,
|
||||
) async {
|
||||
final result = await _decoratee.load(param);
|
||||
final dividedResult = result.map((e) {
|
||||
return EnergyDataModel(
|
||||
date: e.date,
|
||||
value: e.value / 100,
|
||||
);
|
||||
});
|
||||
return dividedResult.toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user