get the last update of one device

This commit is contained in:
Cayo Puigdefabregas 2022-09-20 17:25:09 +02:00
parent b1736f68af
commit c3aa1edd5a
2 changed files with 9 additions and 1 deletions

View file

@ -629,6 +629,14 @@ class Device(Thing):
return self.binding.device.devicehub_id
return self.devicehub_id
@property
def get_updated(self):
if self.placeholder and self.placeholder.binding:
return max([self.updated, self.placeholder.binding.updated])
if self.binding:
return max([self.updated, self.binding.device.updated])
return self.updated
@declared_attr
def __mapper_args__(cls):
"""Defines inheritance.

View file

@ -437,7 +437,7 @@
<td>{% if dev.status %}{{ dev.status.type }}{% endif %}</td>
<td>{% if dev.allocated_status %}{{ dev.allocated_status.type }}{% endif %}</td>
<td>{% if dev.physical_status %}{{ dev.physical_status.type }}{% endif %}</td>
<td>{{ dev.updated.strftime('%Y-%m-%d %H:%M:%S')}}</td>
<td>{{ dev.get_updated.strftime('%Y-%m-%d %H:%M:%S')}}</td>
<td>{{ dev.created.strftime('%Y-%m-%d %H:%M:%S')}}</td>
<td>
<a href="{{ dev.public_link }}" target="_blank">