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
=== modified file 'loco_directory/events/views.py'
--- loco_directory/events/views.py 2011-03-18 13:37:13 +0000
+++ loco_directory/events/views.py 2011-11-13 11:48:23 +0000
@@ -6,6 +6,7 @@
6from django.utils import simplejson6from django.utils import simplejson
7from django.utils.translation import ugettext as _7from django.utils.translation import ugettext as _
8from django.core.urlresolvers import reverse8from django.core.urlresolvers import reverse
9from django.db.models import Count
910
10from events.models import TeamEvent11from events.models import TeamEvent
11from events.models import GlobalEvent12from events.models import GlobalEvent
@@ -88,8 +89,8 @@
88 """89 """
89 a list with all historical events (teamevents and globalevents)90 a list with all historical events (teamevents and globalevents)
90 """91 """
91 team_event_list = TeamEvent.objects.history_events()92 team_event_list = TeamEvent.objects.history_events().select_related('global_event', 'venue')
92 global_event_list = GlobalEvent.objects.history_events()93 global_event_list = GlobalEvent.objects.history_events().annotate(num_teamevents=Count('teamevent'))
93 context = {94 context = {
94 'team_event_list': team_event_list,95 'team_event_list': team_event_list,
95 'global_event_list': global_event_list,96 'global_event_list': global_event_list,
9697
=== modified file 'loco_directory/templates/events/global_event_list.inc.html'
--- loco_directory/templates/events/global_event_list.inc.html 2011-07-23 22:54:02 +0000
+++ loco_directory/templates/events/global_event_list.inc.html 2011-11-13 11:48:23 +0000
@@ -18,7 +18,7 @@
18 </td>18 </td>
19 <td class="event_begin no-wrap">{{global_event.date_begin|date}}</td>19 <td class="event_begin no-wrap">{{global_event.date_begin|date}}</td>
20 <td class="event_end no-wrap">{{global_event.date_end|date}}</td>20 <td class="event_end no-wrap">{{global_event.date_end|date}}</td>
21 <td class="event_teams no-wrap">{{global_event.teamevent_set.all.count}}</td>21 <td class="event_teams no-wrap">{{global_event.num_teamevents}}</td>
22 </tr>22 </tr>
23 {% endfor %}23 {% endfor %}
24 </tbody>24 </tbody>
2525
=== modified file 'loco_directory/templates/events/team_event_list.inc.html'
--- loco_directory/templates/events/team_event_list.inc.html 2011-07-20 17:40:18 +0000
+++ loco_directory/templates/events/team_event_list.inc.html 2011-11-13 11:48:23 +0000
@@ -25,8 +25,8 @@
25 {% endif %}25 {% endif %}
26 {% endfor %}26 {% endfor %}
27 </td>27 </td>
28 <td class="event_begin no-wrap">{{team_event.local_date_begin|date}} {{ team_event.local_date_begin|date:"H:i T"}}</td>28 <td class="event_begin no-wrap">{{team_event.local_date_begin|date:"N j, Y H:i T"}}</td>
29 <td class="event_end no-wrap">{{team_event.local_date_end|date}} {{ team_event.local_date_end|date:"H:i T"}}</td>29 <td class="event_end no-wrap">{{ team_event.local_date_end|date:"N j, Y H:i T"}}</td>
30 <td class="event_global no-wrap">30 <td class="event_global no-wrap">
31 {% if team_event.global_event %}31 {% if team_event.global_event %}
32 <a href="{{ team_event.global_event.get_absolute_url }}">{{ team_event.global_event.name}}</a>32 <a href="{{ team_event.global_event.get_absolute_url }}">{{ team_event.global_event.name}}</a>

Subscribers

People subscribed via source and target branches