Skip to content

Commit

Permalink
Prevent media_duration warnings and null values from events API
Browse files Browse the repository at this point in the history
Merge pull request #712 from bluecherrydvr/web_mediaduration_fix
  • Loading branch information
andrey-utkin authored Nov 18, 2024
2 parents 5f09a71 + aef718d commit 252fd3e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion www/ajax/events/eventsIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public function __construct()
$this->chAccess('backup');
}

// This function handles API endpoint /events/ used by client app.
public function getData()
{
$current_user = $this->user;
Expand All @@ -18,7 +19,7 @@ public function getData()
$events_portion = 5000;

$query = "SELECT EventsCam.*, Media.size AS media_size, Media.start, Media.end, Devices.device_name, ((Media.size>0 OR Media.end=0) AND Media.filepath!='') AS media_available, ".
"IFNULL(TIMESTAMPDIFF(SECOND, Media.start, Media.end), 0) AS video_duration ".
"IFNULL(TIMESTAMPDIFF(SECOND, Media.start, Media.end), 0) AS media_duration ".
"FROM EventsCam ".
"LEFT JOIN Media ON (EventsCam.media_id=Media.id) ".
"LEFT JOIN Devices ON (EventsCam.device_id=Devices.id) ".
Expand Down

0 comments on commit 252fd3e

Please sign in to comment.