manually parse event date for heatmap date object. (#300)

<!--
  Thanks for contributing!

Provide a description of your changes below and a general summary in the
title

Please look at the following checklist to ensure that your PR can be
accepted quickly:
-->



## Description

<!--- Describe your changes in detail -->

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [ ]  New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ]  Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] 🧹 Code refactor
- [ ]  Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore
This commit is contained in:
Faris Armoush
2025-06-27 15:29:39 +03:00
committed by GitHub

View File

@ -14,13 +14,16 @@ class OccupancyHeatMapModel extends Equatable {
});
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
final eventDate = json['event_date'] as String? ?? '${DateTime.now()}';
final year = eventDate.split('-')[0];
final month = eventDate.split('-')[1];
final day = eventDate.split('-')[2];
return OccupancyHeatMapModel(
uuid: json['uuid'] as String? ?? '',
eventDate: DateTime.parse(
json['event_date'] as String? ?? '${DateTime.now()}',
),
eventDate: DateTime(int.parse(year), int.parse(month), int.parse(day)),
countTotalPresenceDetected: num.parse(
json['count_total_presence_detected']?.toString() ?? '900',
json['count_total_presence_detected']?.toString() ?? '0',
).toInt(),
);
}