diff --git a/app/Console/Commands/DeviceLogReportCommand.php b/app/Console/Commands/DeviceLogReportCommand.php index 369f217..6689010 100644 --- a/app/Console/Commands/DeviceLogReportCommand.php +++ b/app/Console/Commands/DeviceLogReportCommand.php @@ -68,7 +68,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */ @@ -109,7 +109,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */ @@ -150,7 +150,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */ diff --git a/app/Services/DeviceLogService.php b/app/Services/DeviceLogService.php index 6c185ca..713c822 100644 --- a/app/Services/DeviceLogService.php +++ b/app/Services/DeviceLogService.php @@ -45,6 +45,10 @@ class DeviceLogService } foreach ($data['content'] as $item) { + if (! isset($item['data'])) { + continue; + } + $isSoilMonitoring = Arr::hasAny($item['data'], [ 'soil_humidity', 'soil_temperature',