better error handling around latest_data
In satellite_card.html we assume if telemetry_data_count returns a value then latest_data will also run fine. This adds some better handling in the off chance that it does not (like in an odd cache state) Signed-off-by: Corey Shields <cshields@gmail.com>spacecruft
parent
33dd436cc1
commit
c217f66b2d
|
@ -326,6 +326,7 @@ class Satellite(models.Model):
|
|||
data = DemodData.objects.filter(
|
||||
Q(satellite=self.id) | Q(satellite__associated_satellite=self.id)
|
||||
).order_by('-id')[:1]
|
||||
if data:
|
||||
latest_datum = data[0]
|
||||
return {
|
||||
'data_id': latest_datum.data_id,
|
||||
|
@ -335,6 +336,7 @@ class Satellite(models.Model):
|
|||
'station': latest_datum.station,
|
||||
'observer': latest_datum.observer,
|
||||
}
|
||||
return None
|
||||
|
||||
@property
|
||||
def needs_help(self):
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% with latest_data=satellite.latest_data %}
|
||||
{% if latest_data %}
|
||||
<div class="d-flex flex-row">
|
||||
<div class="d-flex satellite-card-body-row align-self-center justify-content-center" data-toggle="tooltip"
|
||||
title="Latest data timestamp">
|
||||
|
@ -71,6 +72,7 @@
|
|||
{{ latest_data.station }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% else %}
|
||||
<div class="d-flex flex-row">
|
||||
|
|
Loading…
Reference in New Issue