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.binding.device.devicehub_id
return self.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 @declared_attr
def __mapper_args__(cls): def __mapper_args__(cls):
"""Defines inheritance. """Defines inheritance.

View File

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