mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Otimize DB request for the right page
Reimplement end_adhesion and is_adherent methods in the query itself so it can be done in a single query and not done for each user individually.
This commit is contained in:
parent
324b48d37a
commit
6a08e14165
2 changed files with 7 additions and 4 deletions
|
@ -70,7 +70,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% for user in superusers %}
|
{% for user in superusers %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.pseudo }}</td>
|
<td>{{ user.pseudo }}</td>
|
||||||
{% if user.is_adherent %}
|
{% if user.end_adhesion is not None and user.end_adhesion >= now %}
|
||||||
<td class="text-success">{% trans "Member" %}</td>
|
<td class="text-success">{% trans "Member" %}</td>
|
||||||
{% elif not user.end_adhesion %}
|
{% elif not user.end_adhesion %}
|
||||||
<td class="text-warning">{% trans "No membership records" %}</td>
|
<td class="text-warning">{% trans "No membership records" %}</td>
|
||||||
|
@ -175,7 +175,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.pseudo }}</td>
|
<td>{{ user.pseudo }}</td>
|
||||||
{% if user.is_adherent %}
|
{% if user.end_adhesion is not None and user.end_adhesion >= now %}
|
||||||
<td class="text-success">{% trans "Member" %}</td>
|
<td class="text-success">{% trans "Member" %}</td>
|
||||||
{% elif not user.end_adhesion %}
|
{% elif not user.end_adhesion %}
|
||||||
<td class="text-warning">{% trans "No membership records" %}</td>
|
<td class="text-warning">{% trans "No membership records" %}</td>
|
||||||
|
|
|
@ -811,15 +811,18 @@ def index_listright(request):
|
||||||
.order_by('name')
|
.order_by('name')
|
||||||
.prefetch_related('permissions')
|
.prefetch_related('permissions')
|
||||||
.prefetch_related('user_set')
|
.prefetch_related('user_set')
|
||||||
|
.prefetch_related('user_set__facture_set__vente_set__cotisation')
|
||||||
):
|
):
|
||||||
rights[right] = (right.user_set
|
rights[right] = (right.user_set
|
||||||
.annotate(action_number=Count('revision'),
|
.annotate(action_number=Count('revision'),
|
||||||
last_seen=Max('revision__date_created'))
|
last_seen=Max('revision__date_created'),
|
||||||
|
end_adhesion=Max('facture__vente__cotisation__date_end'))
|
||||||
)
|
)
|
||||||
superusers = (User.objects
|
superusers = (User.objects
|
||||||
.filter(is_superuser=True)
|
.filter(is_superuser=True)
|
||||||
.annotate(action_number=Count('revision'),
|
.annotate(action_number=Count('revision'),
|
||||||
last_seen=Max('revision__date_created'))
|
last_seen=Max('revision__date_created'),
|
||||||
|
end_adhesion=Max('facture__vente__cotisation__date_end'))
|
||||||
)
|
)
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
|
|
Loading…
Reference in a new issue