Skip to content

Commit 248c2dd

Browse files
committed
Added back the on-agenda calendar links to document lists, now in an implementation with better performance characteristics.
- Legacy-Id: 15020
1 parent 2bb5788 commit 248c2dd

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

ietf/doc/utils_search.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ietf.community.utils import augment_docs_with_tracking_info
77
from ietf.doc.models import Document, DocAlias, RelatedDocument, DocEvent, TelechatDocEvent, BallotDocEvent
88
from ietf.doc.expire import expirable_draft
9-
9+
from ietf.meeting.models import SessionPresentation, Meeting, Session
1010

1111
def wrap_value(v):
1212
return lambda: v
@@ -26,6 +26,21 @@ def fill_in_telechat_date(docs, doc_dict=None, doc_ids=None):
2626
d.telechat_date = wrap_value(d.telechat_date(e))
2727
seen.add(e.doc_id)
2828

29+
def fill_in_document_sessions(docs, doc_dict, doc_ids):
30+
beg_date = datetime.date.today()-datetime.timedelta(days=7)
31+
end_date = datetime.date.today()+datetime.timedelta(days=30)
32+
meetings = Meeting.objects.filter(date__gte=beg_date, date__lte=end_date).prefetch_related('session_set')
33+
# get sessions
34+
sessions = Session.objects.filter(meeting_id__in=[ m.id for m in meetings ])
35+
# get presentations
36+
presentations = SessionPresentation.objects.filter(session_id__in=[ s.id for s in sessions ])
37+
session_list = [ (p.document_id, p.session) for p in presentations ]
38+
for d in doc_dict.values():
39+
d.sessions = []
40+
for (i, s) in session_list:
41+
if i in doc_ids:
42+
doc_dict[i].sessions.append(s)
43+
2944
def fill_in_document_table_attributes(docs, have_telechat_date=False):
3045
# fill in some attributes for the document table results to save
3146
# some hairy template code and avoid repeated SQL queries
@@ -58,14 +73,8 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
5873
fill_in_telechat_date(docs, doc_dict, doc_ids)
5974

6075
# on agenda in upcoming meetings
61-
sessions = {}
62-
# debug.mark()
63-
# presentations = SessionPresentation.objects.filter(session__meeting__date__gte=datetime.date.today()-datetime.timedelta(days=7)).select_related('session', 'document')
64-
# session_list = [ (p.document, p.session) for p in presentations ]
65-
# sessions = dict( (d, []) for (d, s) in session_list )
66-
# for (d, s) in session_list:
67-
# sessions[d].append(s)
68-
# debug.clock('presentations')
76+
# get meetings
77+
fill_in_document_sessions(docs, doc_dict, doc_ids)
6978

7079
# misc
7180
for d in docs:
@@ -95,8 +104,6 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
95104
d.milestones = [ m for (t, m) in sorted(((m.time, m) for m in d.groupmilestone_set.all() if m.state_id == "active")) ]
96105
d.reviewed_by_teams = sorted(set(r.team.acronym for r in d.reviewrequest_set.filter(state__in=["requested","accepted","part-completed","completed"]).distinct().select_related('team')))
97106

98-
d.sessions = sessions[d] if d in sessions else []
99-
100107
e = d.latest_event_cache.get('started_iesg_proces', None)
101108
d.balloting_started = e.time if e else datetime.datetime.min
102109

ietf/templates/doc/search/search_result_row.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<a href="{% url "ietf.community.views.track_document" username=request.user.username name=doc.name %}" class="track-untrack-doc {% if doc.tracked_in_personal_community_list %}hide{% endif %}" title="Add to your personal ID list">
2020
<span class="fa fa-bookmark-o"></span>
2121
</a>
22+
<br>
2223
{% endif %}
2324
{% for session in doc.sessions %}
24-
<br><small>
2525
<a href="{% url 'ietf.meeting.views.ical_agenda' num=session.meeting.number session_id=session.id %}"
2626
title="Calendar entry: document is on the agenda for {{ session.group.acronym }}@{{ session.meeting }}">
27-
<span class="fa fa-calendar"></span>
27+
{# font-size set to make the width of fa-calendar come out the same as fa-bookmark-o above: #}
28+
<span class="fa fa-calendar" style="font-size: 75%"></span>
2829
</a>
29-
</small>
3030
{% endfor %}
3131
</td>
3232

0 commit comments

Comments
 (0)