From d1bb8da4848bdbfc4bde0a6b870f0fa0e79b7afe Mon Sep 17 00:00:00 2001 From: Faris Armoush Date: Wed, 14 May 2025 10:51:19 +0300 Subject: [PATCH] Updated `OccupancyHeatMapModel` model with what the api returns, and only used the necessary fields that the api returns for this feature to work. --- .../models/occupancy_heat_map_model.dart | 20 ++++++++++++------- .../widgets/occupancy_heat_map_box.dart | 5 ++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/pages/analytics/models/occupancy_heat_map_model.dart b/lib/pages/analytics/models/occupancy_heat_map_model.dart index 52016cc9..73e7d5d7 100644 --- a/lib/pages/analytics/models/occupancy_heat_map_model.dart +++ b/lib/pages/analytics/models/occupancy_heat_map_model.dart @@ -1,22 +1,28 @@ import 'package:equatable/equatable.dart'; class OccupancyHeatMapModel extends Equatable { - final DateTime date; + final String uuid; - final int occupancy; + final DateTime eventDate; + + final int countTotalPresenceDetected; const OccupancyHeatMapModel({ - required this.date, - required this.occupancy, + required this.uuid, + required this.eventDate, + required this.countTotalPresenceDetected, }); factory OccupancyHeatMapModel.fromJson(Map json) { return OccupancyHeatMapModel( - date: DateTime.parse(json['date'] as String), - occupancy: json['occupancy'] as int, + uuid: json['uuid'] as String? ?? '', + eventDate: DateTime.parse( + json['event_date'] as String? ?? '${DateTime.now()}', + ), + countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0, ); } @override - List get props => [date, occupancy]; + List get props => [uuid, eventDate, countTotalPresenceDetected]; } diff --git a/lib/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_box.dart b/lib/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_box.dart index c4cda268..d52604bf 100644 --- a/lib/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_box.dart +++ b/lib/pages/analytics/modules/occupancy/widgets/occupancy_heat_map_box.dart @@ -68,7 +68,10 @@ class OccupancyHeatMapBox extends StatelessWidget { Expanded( child: OccupancyHeatMap( heatMapData: state.heatMapData.asMap().map( - (_, value) => MapEntry(value.date, value.occupancy), + (_, value) => MapEntry( + value.eventDate, + value.countTotalPresenceDetected, + ), ), ), ),