1
0
Fork 0

Merge branch 'performance-improvements' into 'master'

Performance improvements in user and station page

See merge request librespacefoundation/satnogs/satnogs-network!795
merge-requests/795/merge
Alfredos-Panagiotis Damkalis 2019-11-28 14:59:50 +00:00
commit 933478f43b
3 changed files with 21 additions and 17 deletions

View File

@ -117,20 +117,22 @@
</span>
</div>
{% endif %}
{% if station.observations_count %}
<div class="front-line">
<span class="label label-default">Observations</span>
<span class="front-data">{{ station.observations_count }}
<div class="pull-right">
<a href="{% url 'base:observations_list' %}?station={{ station.id }}">
<button type="button" class="btn btn-xs btn-info">
View all
</button>
</a>
</div>
</span>
</div>
{% endif %}
{% with total_obs=station.observations_count %}
{% if total_obs %}
<div class="front-line">
<span class="label label-default">Observations</span>
<span class="front-data">{{ total_obs }}
<div class="pull-right">
<a href="{% url 'base:observations_list' %}?station={{ station.id }}">
<button type="button" class="btn btn-xs btn-info">
View all
</button>
</a>
</div>
</span>
</div>
{% endif %}
{% endwith %}
<div class="front-line">
<span class="label label-default">Creation Date</span>
<span class="front-data"

View File

@ -42,7 +42,7 @@
<th>Antennas</th>
</thead>
<tbody>
{% for station in stations.all %}
{% for station in stations %}
<tr class="clickable-row" data-href="{% url 'base:station_view' station_id=station.id %}">
<td>
<a href="{% url 'base:station_view' station_id=station.id %}">
@ -145,7 +145,7 @@
<th>Station</th>
</thead>
<tbody>
{% for observation in observations.all %}
{% for observation in observations %}
<tr class="clickable-row" data-href="{% url 'base:observation_view' observation_id=observation.id %}">
<td>
<a href="{% url 'base:observation_view' observation_id=observation.id %}">

View File

@ -37,7 +37,9 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
def view_user(request, username):
"""View for user page."""
user = get_object_or_404(User, username=username)
observations = Observation.objects.filter(author=user)[0:10]
observations = Observation.objects.filter(
author=user
)[0:10].prefetch_related('satellite', 'ground_station')
stations = Station.objects.filter(owner=user).annotate(total_obs=Count('observations'))
token = ''