fix: handle unloaded device association on sites map
site.device is %Ecto.Association.NotLoaded{} since list_organization_sites/1
only preloads :parent_site, causing length/1 to crash the LiveView mount.
This commit is contained in:
parent
6c90e8bd4f
commit
2b3111357e
1 changed files with 1 additions and 1 deletions
|
|
@ -56,7 +56,7 @@ defmodule ToweropsWeb.MapLive.Index do
|
|||
address: site.address,
|
||||
latitude: site.latitude,
|
||||
longitude: site.longitude,
|
||||
device_count: length(site.device || [])
|
||||
device_count: if(is_list(site.device), do: length(site.device), else: 0)
|
||||
}
|
||||
end)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue