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 765ce0d0b0
This commit is contained in:
Henrik Levkowetz 2019-08-04 15:44:06 +00:00
commit 41c6bbf62e
8 changed files with 116 additions and 84 deletions

View file

@ -26,31 +26,40 @@ def expirable_draft(draft):
if draft.type_id != 'draft':
return False
log.assertion('draft.get_state_slug("draft-iesg")')
# return (draft.expires and draft.get_state_slug() == "active"
# and draft.get_state_slug("draft-iesg") in ("idexists", "watching", "dead")
# and draft.get_state_slug("draft-stream-%s" % draft.stream_id) not in ("rfc-edit", "pub")
# and not draft.tags.filter(slug="rfc-rev"))
return bool(expirable_drafts(Document.objects.filter(pk=draft.pk)))
nonexpirable_states = []
def expirable_drafts(queryset=None):
"""Return a queryset with expirable drafts."""
global nonexpirable_states
# the general rule is that each active draft is expirable, unless
# it's in a state where we shouldn't touch it
if not queryset:
queryset = Document.objects.all()
d = queryset.filter(states__type="draft", states__slug="active").exclude(expires=None)
# Populate this first time through (but after django has been set up)
if nonexpirable_states == []:
# all IESG states except I-D Exists, AD Watching, and Dead block expiry
nonexpirable_states += list(State.objects.filter(used=True, type="draft-iesg").exclude(slug__in=("idexists","watching", "dead")))
# sent to RFC Editor and RFC Published block expiry (the latter
# shouldn't be possible for an active draft, though)
nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub")))
# other IRTF states that block expiration
nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",)))
nonexpirable_states = []
# all IESG states except I-D Exists, AD Watching, and Dead block expiry
nonexpirable_states += list(State.objects.filter(used=True, type="draft-iesg").exclude(slug__in=("idexists","watching", "dead")))
# sent to RFC Editor and RFC Published block expiry (the latter
# shouldn't be possible for an active draft, though)
nonexpirable_states += list(State.objects.filter(used=True, type__in=("draft-stream-iab", "draft-stream-irtf", "draft-stream-ise"), slug__in=("rfc-edit", "pub")))
# other IRTF states that block expiration
nonexpirable_states += list(State.objects.filter(used=True, type_id="draft-stream-irtf", slug__in=("irsgpoll", "iesg-rev",)))
d = queryset.filter(states__type="draft", states__slug="active")
if not d.exists():
return d
d = d.exclude(expires=None)
if not d.exists():
return d
d = d.exclude(states__in=nonexpirable_states)
if not d.exists():
return d
# under review by the RFC Editor blocks expiry
d = d.exclude(tags="rfc-rev")

View file

@ -94,16 +94,22 @@ def fill_in_document_table_attributes(docs, have_telechat_date=False):
d.latest_revision_date = d.time
if d.type_id == "draft":
if d.get_state_slug() == "rfc":
state_slug = d.get_state_slug()
if state_slug == "rfc":
d.search_heading = "RFC"
elif d.get_state_slug() in ("ietf-rm", "auth-rm"):
d.expirable = False
elif state_slug in ("ietf-rm", "auth-rm"):
d.search_heading = "Withdrawn Internet-Draft"
d.expirable = False
else:
d.search_heading = "%s Internet-Draft" % d.get_state()
if state_slug == "active":
d.expirable = expirable_draft(d)
else:
d.expirable = False
else:
d.search_heading = "%s" % (d.type,);
d.expirable = expirable_draft(d)
d.search_heading = "%s" % (d.type,)
d.expirable = False
if d.get_state_slug() != "rfc":
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):
displaying a full table of information about the documents, plus
dict with information about the columns."""
if docs.count() > max_results:
docs = docs[:max_results]
if not isinstance(docs, list):
# evaluate and fill in attribute results immediately to decrease
# the number of queries
docs = docs.select_related("ad", "std_level", "intended_std_level", "group", "stream", "shepherd", )
docs = docs.prefetch_related("states__type", "tags", "groupmilestone_set__group", "reviewrequest_set__team",
"submission_set__checks", "ad__email_set", "docalias__iprdocrel_set")
if docs.count() > max_results:
docs = docs[:max_results]
docs = list(docs)
docs = list(docs)
fill_in_document_table_attributes(docs)
augment_docs_with_tracking_info(docs, request.user)

View file

@ -1056,7 +1056,7 @@ class Session(models.Model):
return 'sess%s' % (string.ascii_lowercase[index])
def constraints(self):
return Constraint.objects.filter(source=self.group, meeting=self.meeting).order_by('name__name')
return Constraint.objects.filter(source=self.group, meeting=self.meeting).order_by('name__name').prefetch_related("source","target","person")
def reverse_constraints(self):
return Constraint.objects.filter(target=self.group, meeting=self.meeting).order_by('name__name')

View file

@ -1043,9 +1043,9 @@ def json_agenda(request, num=None ):
def meeting_requests(request, num=None):
meeting = get_meeting(num)
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")
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")
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")
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")
return render(request, "meeting/requests.html",
{"meeting": meeting, "sessions":sessions,

View file

@ -49,44 +49,45 @@
{% if user and user.is_authenticated %}
<li><a href="{% url "ietf.community.views.view_list" user.username %}">My tracked docs</a></li>
{% if user|has_role:"Area Director,Secretariat" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li><a href="{% url 'ietf.doc.views_status_change.rfc_status_changes' %}">RFC status changes</a></li>
{% endif %}
{% if user|has_role:"WG Chair,RG Chair" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>WG chair</li>
<li><a href="{% url "ietf.submit.views.approvals" %}">Approve a draft</a></li>
{% for g in user|docman_groups %}
<li><a href="{% url "ietf.group.views.group_documents" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
{% endfor %}
{% for g in user|matman_groups %}
<li><a href="{% url "ietf.group.views.meetings" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} meetings</a></li>
{% endfor %}
{% endif %}
{% if user|has_role:"Review Team Secretary" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Review Teams</li>
{% for g in user|managed_review_groups %}
<li><a href="{% url "ietf.group.views.review_requests" g.acronym %}">{{ g.acronym }} reviews</a></li>
{% endfor %}
{% endif %}
{% if user|active_nomcoms %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Nomcoms</li>
{% for g in user|active_nomcoms %}
<li><a href="{% url "ietf.nomcom.views.private_index" g.nomcom_set.first.year %}">{{ g.acronym|capfirst }}</a></li>
{% endfor %}
{% endif %}
{% else %}
<li><a rel="nofollow" href="/accounts/login/?next={{ request.get_full_path|urlencode }}">Sign in to track docs</a></li>
{% endif %}
{% if user|has_role:"Area Director,Secretariat" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li><a href="{% url 'ietf.doc.views_status_change.rfc_status_changes' %}">RFC status changes</a></li>
{% endif %}
{% if user|has_role:"WG Chair,RG Chair" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>WG chair</li>
<li><a href="{% url "ietf.submit.views.approvals" %}">Approve a draft</a></li>
{% for g in user|docman_groups %}
<li><a href="{% url "ietf.group.views.group_documents" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} docs</a></li>
{% endfor %}
{% for g in user|matman_groups %}
<li><a href="{% url "ietf.group.views.meetings" g.acronym %}">{{ g.acronym }} {{ g.type.slug }} meetings</a></li>
{% endfor %}
{% endif %}
{% if user|has_role:"Review Team Secretary" %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Review Teams</li>
{% for g in user|managed_review_groups %}
<li><a href="{% url "ietf.group.views.review_requests" g.acronym %}">{{ g.acronym }} reviews</a></li>
{% endfor %}
{% endif %}
{% if user|active_nomcoms %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>Nomcoms</li>
{% for g in user|active_nomcoms %}
<li><a href="{% url "ietf.nomcom.views.private_index" g.nomcom_set.first.year %}">{{ g.acronym|capfirst }}</a></li>
{% endfor %}
{% endif %}
{% if flavor == "top" %}<li class="divider hidden-xs"></li>{% endif %}
<li {%if flavor == "top" %}class="dropdown-header hidden-xs"{% else %}class="nav-header"{% endif %}>RFC streams</li>

View file

@ -7,14 +7,20 @@
{% block content %}
<h1>IETF {{ meeting_num }} meeting materials that you can edit</h1>
{% if user and user.is_authenticated and user|matman_groups %}
{% for g in user|matman_groups %}
{% if g|has_sessions:meeting_num %}
<p><a href="{% url 'ietf.meeting.views.session_details' num=meeting_num acronym=g.acronym %}">{{ g.acronym }}</a></p>
{% else %}
<p>{{ g.acronym }} (No session requested) </p>
{% endif %}
{% endfor %}
{% if user and user.is_authenticated %}
{% with user|matman_groups as user_groups %}
{% if user_groups %}
{% for g in user_groups %}
{% if g|has_sessions:meeting_num %}
<p><a href="{% url 'ietf.meeting.views.session_details' num=meeting_num acronym=g.acronym %}">{{ g.acronym }}</a></p>
{% else %}
<p>{{ g.acronym }} (No session requested) </p>
{% endif %}
{% endfor %}
{% else %}
<p>You cannot manage the meeting materials for any groups.</p>
{% endif %}
{% endwith %}
{% else %}
<p>You cannot manage the meeting materials for any groups.</p>
{% endif %}

View file

@ -90,19 +90,27 @@
{% ifchanged grouped_constraint.grouper %}<br>{% endifchanged %}
{% endif %}
{% for constraint in grouped_constraint.list %}
{% if constraint.target.parent.id == constraint.source.parent.id and not constraint.person %}
<b>
{% endif %}
{% if constraint.name.slug == "bethere" %}
{{constraint.brief_display|clean_whitespace}}{% if not forloop.last %}, {% endif %}
{% else %}
<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 %}">
{{constraint.brief_display}}
</span>
{% endif %}
{% if constraint.target.parent.id == constraint.source.parent.id and not constraint.person %}
</b>
{% endif %}
{% with constraint.target.parent.id as constraint_target_parent_id %}
{% with constraint.source.parent.id as constraint_source_parent_id %}
{% with constraint.person as constraint_person %}
{% if constraint_target_parent_id == constraint_source_parent_id and not constraint_person %}
<b>
{% endif %}
{% if constraint.name.slug == "bethere" %}
{{constraint.brief_display|clean_whitespace}}{% if not forloop.last %}, {% endif %}
{% else %}
{% with constraint.name.slug as constraint_name_slug %}
<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 %}">
{% endwith %}
{{constraint.brief_display}}
</span>
{% endif %}
{% if constraint_target_parent_id == constraint_source_parent_id and not constraint_person %}
</b>
{% endif %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endfor %}
{% endfor %}
{% endif %}

View file

@ -1,15 +1,17 @@
# By saying 'Commit ready for merge' in the commit message when you commit a
# change to your branch, the commit will be included in the merge list for the
# next release. However, if a commit for some reason haven't is missing that
# phrase in the commit comment, the branch and revision of the changeset can
# be added to this file in trunk/ by the merge master, and it will also be
# included in the merge list.
# next release. However, if a commit for some reason is missing that phrase
# in the commit comment, the branch and revision of the changeset can be added
# to this file in trunk/ by the merge master, and it will also be included in
# the merge list.
# --- Add entries at the top ---
/personal/rjs/6.99.2.dev0@16603
/personal/rjs/6.99.2.dev0@16601
/personal/housley/6.99.2.dev0@16563
/personal/housley/6.94.2.dev0@16126
/personal/housley/6.94.2.dev0@16125
/personal/housley/6.94.2.dev0@16087