Improve day swipe and sleep handling
This commit is contained in:
+11
-4
@@ -739,7 +739,9 @@ final class App
|
||||
|
||||
if ($name === 'sleep_analysis') {
|
||||
foreach ($data as $point) {
|
||||
$date = $this->healthPointDate($point['date'] ?? ($point['sleepEnd'] ?? ($point['endDate'] ?? null)));
|
||||
$start = $this->healthDateTime($point['sleepStart'] ?? ($point['inBedStart'] ?? ($point['startDate'] ?? null)));
|
||||
$end = $this->healthDateTime($point['sleepEnd'] ?? ($point['inBedEnd'] ?? ($point['endDate'] ?? null)));
|
||||
$date = ($end ?? $this->healthDateTime($point['date'] ?? null))?->format('Y-m-d');
|
||||
if ($date === null) {
|
||||
continue;
|
||||
}
|
||||
@@ -770,8 +772,6 @@ final class App
|
||||
}
|
||||
}
|
||||
|
||||
$start = $this->healthDateTime($point['sleepStart'] ?? ($point['inBedStart'] ?? ($point['startDate'] ?? null)));
|
||||
$end = $this->healthDateTime($point['sleepEnd'] ?? ($point['inBedEnd'] ?? ($point['endDate'] ?? null)));
|
||||
if ($start !== null && ($bucket['start'] === null || $start < $bucket['start'])) {
|
||||
$bucket['start'] = $start;
|
||||
}
|
||||
@@ -1816,7 +1816,7 @@ final class App
|
||||
|
||||
$comment = trim((string) ($input['event_comment'] ?? ''));
|
||||
|
||||
$value = max(0, min(50000, (float) ($input['event_value'] ?? 0)));
|
||||
$value = max(0, min(50000, $this->localizedFloat($input['event_value'] ?? 0)));
|
||||
if (in_array($type, ['walk', 'sport', 'sleep'], true) && $value <= 0) {
|
||||
throw new RuntimeException('Für diesen Moment braucht es einen Wert oder eine Dauer.');
|
||||
}
|
||||
@@ -1847,6 +1847,13 @@ final class App
|
||||
];
|
||||
}
|
||||
|
||||
private function localizedFloat(mixed $value): float
|
||||
{
|
||||
$normalized = str_replace(',', '.', trim((string) $value));
|
||||
|
||||
return is_numeric($normalized) ? (float) $normalized : 0.0;
|
||||
}
|
||||
|
||||
private function dashboardMediaDirectory(string $username): string
|
||||
{
|
||||
return storage_path('users/' . normalize_username($username) . '/media');
|
||||
|
||||
Reference in New Issue
Block a user