Merge lp:~ronnie.vd.c/loco-team-portal/event-history-reduced-queries into lp:loco-team-portal

Proposed by Ronnie
Status: Merged
Approved by: Chris Johnston
Approved revision: 510
Merged at revision: 513
Proposed branch: lp:~ronnie.vd.c/loco-team-portal/event-history-reduced-queries
Merge into: lp:loco-team-portal
Diff against target: 50 lines (+6/-5)
3 files modified
loco_directory/events/views.py (+3/-2)
loco_directory/templates/events/global_event_list.inc.html (+1/-1)
loco_directory/templates/events/team_event_list.inc.html (+2/-2)
To merge this branch: bzr merge lp:~ronnie.vd.c/loco-team-portal/event-history-reduced-queries
Reviewer Review Type Date Requested Status
Chris Johnston Approve
Review via email: mp+82075@code.launchpad.net

Commit message

Reduced the amount of queries on the event history page bij 33%. From around 5000 to 3000.

Description of the change

Reduced the amount of queries on the event history page bij 33%. From around 5000 to 3000.
The main problem that still exists is the o2m relation between teamevents and teams

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

Works for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/events/views.py'
2--- loco_directory/events/views.py 2011-03-18 13:37:13 +0000
3+++ loco_directory/events/views.py 2011-11-13 11:48:23 +0000
4@@ -6,6 +6,7 @@
5 from django.utils import simplejson
6 from django.utils.translation import ugettext as _
7 from django.core.urlresolvers import reverse
8+from django.db.models import Count
9
10 from events.models import TeamEvent
11 from events.models import GlobalEvent
12@@ -88,8 +89,8 @@
13 """
14 a list with all historical events (teamevents and globalevents)
15 """
16- team_event_list = TeamEvent.objects.history_events()
17- global_event_list = GlobalEvent.objects.history_events()
18+ team_event_list = TeamEvent.objects.history_events().select_related('global_event', 'venue')
19+ global_event_list = GlobalEvent.objects.history_events().annotate(num_teamevents=Count('teamevent'))
20 context = {
21 'team_event_list': team_event_list,
22 'global_event_list': global_event_list,
23
24=== modified file 'loco_directory/templates/events/global_event_list.inc.html'
25--- loco_directory/templates/events/global_event_list.inc.html 2011-07-23 22:54:02 +0000
26+++ loco_directory/templates/events/global_event_list.inc.html 2011-11-13 11:48:23 +0000
27@@ -18,7 +18,7 @@
28 </td>
29 <td class="event_begin no-wrap">{{global_event.date_begin|date}}</td>
30 <td class="event_end no-wrap">{{global_event.date_end|date}}</td>
31- <td class="event_teams no-wrap">{{global_event.teamevent_set.all.count}}</td>
32+ <td class="event_teams no-wrap">{{global_event.num_teamevents}}</td>
33 </tr>
34 {% endfor %}
35 </tbody>
36
37=== modified file 'loco_directory/templates/events/team_event_list.inc.html'
38--- loco_directory/templates/events/team_event_list.inc.html 2011-07-20 17:40:18 +0000
39+++ loco_directory/templates/events/team_event_list.inc.html 2011-11-13 11:48:23 +0000
40@@ -25,8 +25,8 @@
41 {% endif %}
42 {% endfor %}
43 </td>
44- <td class="event_begin no-wrap">{{team_event.local_date_begin|date}} {{ team_event.local_date_begin|date:"H:i T"}}</td>
45- <td class="event_end no-wrap">{{team_event.local_date_end|date}} {{ team_event.local_date_end|date:"H:i T"}}</td>
46+ <td class="event_begin no-wrap">{{team_event.local_date_begin|date:"N j, Y H:i T"}}</td>
47+ <td class="event_end no-wrap">{{ team_event.local_date_end|date:"N j, Y H:i T"}}</td>
48 <td class="event_global no-wrap">
49 {% if team_event.global_event %}
50 <a href="{{ team_event.global_event.get_absolute_url }}">{{ team_event.global_event.name}}</a>

Subscribers

People subscribed via source and target branches