Reduce SQL queries in user page
Signed-off-by: Alfredos-Panagiotis Damkalis <fredy@fredy.gr>merge-requests/795/head 1.16
parent
be174ad4dd
commit
460f6ea66d
|
@ -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 %}">
|
||||
|
|
|
@ -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 = ''
|
||||
|
||||
|
|
Loading…
Reference in New Issue