Skip to content

Commit 41c6bbf

Browse files
committed
Merged in [16563] from housley@vigilsec.com:
Improve performance for a few pages - Legacy-Id: 16613 Note: SVN reference [16563] has been migrated to Git commit 765ce0d
2 parents b541f5c + 765ce0d commit 41c6bbf

8 files changed

Lines changed: 117 additions & 85 deletions

File tree

ietf/doc/expire.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,40 @@ def expirable_draft(draft):
2626
if draft.type_id != 'draft':
2727
return False
2828
log.assertion('draft.get_state_slug("draft-iesg")')
29-
# return (draft.expires and draft.get_state_slug() == "active"
30-
# and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead")
31-
# and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub")
32-
# and not draft.tags.filter(slug="rfc-rev"))
3329
return bool(expirable_drafts(Document.objects.filter(pk=draft.pk)))
3430

31+
nonexpirable_states = []
32+
3533
def expirable_drafts(queryset=None):
3634
"""Return a queryset with expirable drafts."""
35+
global nonexpirable_states
36+
3737
# the general rule is that each active draft is expirable, unless
3838
# it's in a state where we shouldn't touch it
3939
if not queryset:
4040
queryset = Document.objects.all()
4141

42-
d = queryset.filter(states__type="draft", states__slug="active").exclude(expires=None)
43-
44-
nonexpirable_states = []
45-
# all IESG states except I-D Exists, AD Watching, and Dead block expiry
46-
nonexpirable_states += list(State.objects.filter(used=True, type="draft-iesg").exclude(slug__in=("idexists","watching", "dead")))
47-
# sent to RFC Editor and RFC Published block expiry (the latter
48-
# shouldn't be possible for an active draft, though)
49-
nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub")))
50-
# other IRTF states that block expiration
51-
nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",)))
42+
# Populate this first time through (but after django has been set up)
43+
if nonexpirable_states == []:
44+
# all IESG states except I-D Exists, AD Watching, and Dead block expiry
45+
nonexpirable_states += list(State.objects.filter(used=True, type="draft-iesg").exclude(slug__in=("idexists","watching", "dead")))
46+
# sent to RFC Editor and RFC Published block expiry (the latter
47+
# shouldn't be possible for an active draft, though)
48+
nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub")))
49+
# other IRTF states that block expiration
50+
nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",)))
51+
52+
d = queryset.filter(states__type="draft", states__slug="active")
53+
if not d.exists():
54+
return d
55+
56+
d = d.exclude(expires=None)
57+
if not d.exists():
58+
return d
5259

5360
d = d.exclude(states__in=nonexpirable_states)
61+
if not d.exists():
62+
return d
5463

5564
# under review by the RFC Editor blocks expiry
5665
d = d.exclude(tags="rfc-rev")

ietf/doc/utils_search.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,22 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
9494
d.latest_revision_date = d.time
9595

9696
if d.type_id == "draft":
97-
if d.get_state_slug() == "rfc":
97+
state_slug = d.get_state_slug()
98+
if state_slug == "rfc":
9899
d.search_heading = "RFC"
99-
elif d.get_state_slug() in ("ietf-rm", "auth-rm"):
100+
d.expirable = False
101+
elif state_slug in ("ietf-rm", "auth-rm"):
100102
d.search_heading = "Withdrawn Internet-Draft"
103+
d.expirable = False
101104
else:
102105
d.search_heading = "%s Internet-Draft" % d.get_state()
106+
if state_slug == "active":
107+
d.expirable = expirable_draft(d)
108+
else:
109+
d.expirable = False
103110
else:
104-
d.search_heading = "%s" % (d.type,);
105-
106-
d.expirable = expirable_draft(d)
111+
d.search_heading = "%s" % (d.type,)
112+
d.expirable = False
107113

108114
if d.get_state_slug() != "rfc":
109115
d.milestones = [ m for (t, s, v, m) in sorted(((m.time, m.state.slug, m.desc, m) for m in d.groupmilestone_set.all() if m.state_id == "active")) ]
@@ -144,16 +150,16 @@ def prepare_document_table(request, docs, query=None, max_results=200):
144150
displaying a full table of information about the documents, plus
145151
dict with information about the columns."""
146152

153+
if docs.count() > max_results:
154+
docs = docs[:max_results]
155+
147156
if not isinstance(docs, list):
148157
# evaluate and fill in attribute results immediately to decrease
149158
# the number of queries
150159
docs = docs.select_related("ad", "std_level", "intended_std_level", "group", "stream", "shepherd", )
151160
docs = docs.prefetch_related("states__type", "tags", "groupmilestone_set__group", "reviewrequest_set__team",
152161
"submission_set__checks", "ad__email_set", "docalias__iprdocrel_set")
153-
154-
if docs.count() > max_results:
155-
docs = docs[:max_results]
156-
docs = list(docs)
162+
docs = list(docs)
157163

158164
fill_in_document_table_attributes(docs)
159165
augment_docs_with_tracking_info(docs, request.user)

ietf/meeting/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ def docname_token(self):
10561056
return 'sess%s' % (string.ascii_lowercase[index])
10571057

10581058
def constraints(self):
1059-
return Constraint.objects.filter(source=self.group, meeting=self.meeting).order_by('name__name')
1059+
return Constraint.objects.filter(source=self.group, meeting=self.meeting).order_by('name__name').prefetch_related("source","target","person")
10601060

10611061
def reverse_constraints(self):
10621062
return Constraint.objects.filter(target=self.group, meeting=self.meeting).order_by('name__name')

ietf/meeting/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,9 +1043,9 @@ def json_agenda(request, num=None ):
10431043

10441044
def meeting_requests(request, num=None):
10451045
meeting = get_meeting(num)
1046-
sessions = Session.objects.filter(meeting__number=meeting.number, type__slug='session', group__parent__isnull = False).exclude(requested_by=0).order_by("group__parent__acronym","status__slug","group__acronym")
1046+
sessions = Session.objects.filter(meeting__number=meeting.number, type__slug='session', group__parent__isnull = False).exclude(requested_by=0).order_by("group__parent__acronym","status__slug","group__acronym").prefetch_related("group","group__ad_role__person","requested_by")
10471047

1048-
groups_not_meeting = Group.objects.filter(state='Active',type__in=['wg','rg','ag','bof']).exclude(acronym__in = [session.group.acronym for session in sessions]).order_by("parent__acronym","acronym")
1048+
groups_not_meeting = Group.objects.filter(state='Active',type__in=['wg','rg','ag','bof']).exclude(acronym__in = [session.group.acronym for session in sessions]).order_by("parent__acronym","acronym").prefetch_related("parent")
10491049

10501050
return render(request, "meeting/requests.html",
10511051
{"meeting": meeting, "sessions":sessions,

ietf/templates/base/menu.html

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,43 @@
4949

5050
{% if user and user.is_authenticated %}
5151
<li><a href="{% url "ietf.community.views.view_list" user.username %}">My tracked docs</a></li>
52-
{% else %}
53-
<li><a rel="nofollow" href="/accounts/login/?next={{ request.get_full_path|urlencode }}">Sign in to track docs</a></li>
54-
{% endif %}
55-
56-
{% if user|has_role:"Area Director,Secretariat" %}
57-
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
58-
<li><a href="{% url 'ietf.doc.views_status_change.rfc_status_changes' %}">RFC status changes</a></li>
59-
{% endif %}
6052

61-
{% if user|has_role:"WG Chair,RG Chair" %}
62-
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
63-
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>WG chair</li>
64-
<li><a href="{% url "ietf.submit.views.approvals" %}">Approve a draft</a></li>
65-
66-
{% for g in user|docman_groups %}
67-
<li><a href="{% url "ietf.group.views.group_documents" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
68-
{% endfor %}
69-
{% for g in user|matman_groups %}
70-
<li><a href="{% url "ietf.group.views.meetings" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} meetings</a></li>
71-
{% endfor %}
72-
{% endif %}
73-
74-
{% if user|has_role:"Review Team Secretary" %}
75-
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
76-
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Review Teams</li>
77-
{% for g in user|managed_review_groups %}
78-
<li><a href="{% url "ietf.group.views.review_requests" g.acronym %}">{{ g.acronym }} reviews</a></li>
79-
{% endfor %}
80-
{% endif %}
53+
{% if user|has_role:"Area Director,Secretariat" %}
54+
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
55+
<li><a href="{% url 'ietf.doc.views_status_change.rfc_status_changes' %}">RFC status changes</a></li>
56+
{% endif %}
57+
58+
{% if user|has_role:"WG Chair,RG Chair" %}
59+
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
60+
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>WG chair</li>
61+
<li><a href="{% url "ietf.submit.views.approvals" %}">Approve a draft</a></li>
62+
63+
{% for g in user|docman_groups %}
64+
<li><a href="{% url "ietf.group.views.group_documents" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
65+
{% endfor %}
66+
{% for g in user|matman_groups %}
67+
<li><a href="{% url "ietf.group.views.meetings" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} meetings</a></li>
68+
{% endfor %}
69+
{% endif %}
70+
71+
{% if user|has_role:"Review Team Secretary" %}
72+
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
73+
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Review Teams</li>
74+
{% for g in user|managed_review_groups %}
75+
<li><a href="{% url "ietf.group.views.review_requests" g.acronym %}">{{ g.acronym }} reviews</a></li>
76+
{% endfor %}
77+
{% endif %}
78+
79+
{% if user|active_nomcoms %}
80+
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
81+
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Nomcoms</li>
82+
{% for g in user|active_nomcoms %}
83+
<li><a href="{% url "ietf.nomcom.views.private_index" g.nomcom_set.first.year %}">{{ g.acronym|capfirst }}</a></li>
84+
{% endfor %}
85+
{% endif %}
8186

82-
{% if user|active_nomcoms %}
83-
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
84-
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Nomcoms</li>
85-
{% for g in user|active_nomcoms %}
86-
<li><a href="{% url "ietf.nomcom.views.private_index" g.nomcom_set.first.year %}">{{ g.acronym|capfirst }}</a></li>
87-
{% endfor %}
87+
{% else %}
88+
<li><a rel="nofollow" href="/accounts/login/?next={{ request.get_full_path|urlencode }}">Sign in to track docs</a></li>
8889
{% endif %}
8990

9091

ietf/templates/meeting/materials_editable_groups.html

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
{% block content %}
88
<h1>IETF {{ meeting_num }} meeting materials that you can edit</h1>
99

10-
{% if user and user.is_authenticated and user|matman_groups %}
11-
{% for g in user|matman_groups %}
12-
{% if g|has_sessions:meeting_num %}
13-
<p><a href="{% url 'ietf.meeting.views.session_details' num=meeting_num acronym=g.acronym %}">{{ g.acronym }}</a></p>
14-
{% else %}
15-
<p>{{ g.acronym }} (No session requested) </p>
16-
{% endif %}
17-
{% endfor %}
10+
{% if user and user.is_authenticated %}
11+
{% with user|matman_groups as user_groups %}
12+
{% if user_groups %}
13+
{% for g in user_groups %}
14+
{% if g|has_sessions:meeting_num %}
15+
<p><a href="{% url 'ietf.meeting.views.session_details' num=meeting_num acronym=g.acronym %}">{{ g.acronym }}</a></p>
16+
{% else %}
17+
<p>{{ g.acronym }} (No session requested) </p>
18+
{% endif %}
19+
{% endfor %}
20+
{% else %}
21+
<p>You cannot manage the meeting materials for any groups.</p>
22+
{% endif %}
23+
{% endwith %}
1824
{% else %}
1925
<p>You cannot manage the meeting materials for any groups.</p>
2026
{% endif %}

ietf/templates/meeting/requests.html

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,27 @@ <h2 class="anchor-target" id="{{area.grouper.acronym}}">
9090
{% ifchanged grouped_constraint.grouper %}<br>{% endifchanged %}
9191
{% endif %}
9292
{% for constraint in grouped_constraint.list %}
93-
{% if constraint.target.parent.id == constraint.source.parent.id and not constraint.person %}
94-
<b>
95-
{% endif %}
96-
{% if constraint.name.slug == "bethere" %}
97-
{{constraint.brief_display|clean_whitespace}}{% if not forloop.last %}, {% endif %}
98-
{% else %}
99-
<span class="{% if constraint.name.slug == "conflict" %}text-danger{% elif constraint.name.slug == "conflic2" %}text-warning{% elif constraint.name.slug == "conflic3" %}text-success{% else %}{{constraint.name.slug}}{% endif %}">
100-
{{constraint.brief_display}}
101-
</span>
102-
{% endif %}
103-
{% if constraint.target.parent.id == constraint.source.parent.id and not constraint.person %}
104-
</b>
105-
{% endif %}
93+
{% with constraint.target.parent.id as constraint_target_parent_id %}
94+
{% with constraint.source.parent.id as constraint_source_parent_id %}
95+
{% with constraint.person as constraint_person %}
96+
{% if constraint_target_parent_id == constraint_source_parent_id and not constraint_person %}
97+
<b>
98+
{% endif %}
99+
{% if constraint.name.slug == "bethere" %}
100+
{{constraint.brief_display|clean_whitespace}}{% if not forloop.last %}, {% endif %}
101+
{% else %}
102+
{% with constraint.name.slug as constraint_name_slug %}
103+
<span class="{% if constraint_name_slug == "conflict" %}text-danger{% elif constraint_name_slug == "conflic2" %}text-warning{% elif constraint_name_slug == "conflic3" %}text-success{% else %}{{constraint_name_slug}}{% endif %}">
104+
{% endwith %}
105+
{{constraint.brief_display}}
106+
</span>
107+
{% endif %}
108+
{% if constraint_target_parent_id == constraint_source_parent_id and not constraint_person %}
109+
</b>
110+
{% endif %}
111+
{% endwith %}
112+
{% endwith %}
113+
{% endwith %}
106114
{% endfor %}
107115
{% endfor %}
108116
{% endif %}

ready-for-merge

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# By saying 'Commit ready for merge' in the commit message when you commit a
22
# change to your branch, the commit will be included in the merge list for the
3-
# next release. However, if a commit for some reason haven't is missing that
4-
# phrase in the commit comment, the branch and revision of the changeset can
5-
# be added to this file in trunk/ by the merge master, and it will also be
6-
# included in the merge list.
3+
# next release. However, if a commit for some reason is missing that phrase
4+
# in the commit comment, the branch and revision of the changeset can be added
5+
# to this file in trunk/ by the merge master, and it will also be included in
6+
# the merge list.
77

88
# --- Add entries at the top ---
99

1010
/personal/rjs/6.99.2.dev0@16603
1111
/personal/rjs/6.99.2.dev0@16601
1212

13+
/personal/housley/6.99.2.dev0@16563
14+
1315
/personal/housley/6.94.2.dev0@16126
1416
/personal/housley/6.94.2.dev0@16125
1517
/personal/housley/6.94.2.dev0@16087

0 commit comments

Comments
 (0)