Merged in [10636] from rjsparks@nostrum.com:
Refactored counting telechat pages to do it only in one place. Count more accurately and make it possible to report more granularly. Added page counts to agenda.json.
- Legacy-Id: 10658
Note: SVN reference [10636] has been migrated to Git commit 67f0234cac
This commit is contained in:
commit
b66dffe8fa
|
@ -3,7 +3,7 @@ import datetime
|
|||
from django import forms
|
||||
|
||||
from ietf.iesg.models import TelechatDate
|
||||
from ietf.doc.models import Document
|
||||
from ietf.iesg.utils import telechat_page_count
|
||||
|
||||
class TelechatForm(forms.Form):
|
||||
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False, help_text="Page counts are the current page counts for the telechat, before this telechat date edit is made.")
|
||||
|
@ -20,7 +20,7 @@ class TelechatForm(forms.Form):
|
|||
self.page_count = {}
|
||||
choice_display = {}
|
||||
for d in dates:
|
||||
self.page_count[d] = sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distinct() if doc.telechat_date()==d])
|
||||
self.page_count[d] = telechat_page_count(d).for_approval
|
||||
choice_display[d] = '%s (%s pages)' % (d.strftime("%Y-%m-%d"),self.page_count[d])
|
||||
self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, choice_display[d]) for d in dates]
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ def get_doc_section(doc):
|
|||
s += ".3"
|
||||
else:
|
||||
s += ".2"
|
||||
if doc.get_state_slug() != "rfc" and doc.get_state_slug('draft-iesg') not in ("lc", "writeupw", "goaheadw", "iesg-eva", "defer"):
|
||||
if doc.get_state_slug() != "rfc" and doc.get_state_slug('draft-iesg') not in ("lc", "writeupw", "goaheadw", "iesg-eva", "defer", "approved", "ann", "rfcqueue", "pub"):
|
||||
s += ".3"
|
||||
elif doc.returning_item():
|
||||
s += ".2"
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
from django import template
|
||||
|
||||
from ietf.iesg.utils import telechat_page_count as page_counter
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def telechat_page_count(telechat):
|
||||
page_count = 0
|
||||
for num, section in telechat['sections']:
|
||||
if num in ('2.1.1','2.1.2','2.2.1','2.2.2','3.1.1','3.1.2','3.2.1','3.2.2',):
|
||||
for doc in section['docs']:
|
||||
page_count += getattr(doc,'pages',0)
|
||||
return page_count
|
||||
|
||||
# An alternate implementation:
|
||||
# sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distict() if doc.telechat_date()==d])
|
||||
return page_counter(telechat['date']).for_approval
|
||||
|
|
49
ietf/iesg/utils.py
Normal file
49
ietf/iesg/utils.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from collections import namedtuple
|
||||
|
||||
from ietf.doc.models import Document, TelechatDocEvent, STATUSCHANGE_RELATIONS
|
||||
from ietf.iesg.agenda import get_doc_section
|
||||
|
||||
TelechatPageCount = namedtuple('TelechatPageCount',['for_approval','for_action','related'])
|
||||
|
||||
def telechat_page_count(date):
|
||||
|
||||
candidates = Document.objects.filter(docevent__telechatdocevent__telechat_date=date).distinct()
|
||||
|
||||
docs = [ doc for doc in candidates if doc.latest_event(TelechatDocEvent,type='scheduled_for_telechat').telechat_date==date ]
|
||||
|
||||
for_action =[d for d in docs if get_doc_section(d).endswith('.3')]
|
||||
|
||||
for_approval = set(docs)-set(for_action)
|
||||
|
||||
drafts = [d for d in for_approval if d.type_id == 'draft']
|
||||
|
||||
pages_for_approval = sum([d.pages or 0 for d in drafts])
|
||||
|
||||
pages_for_action = 0
|
||||
for d in for_action:
|
||||
if d.type_id == 'draft':
|
||||
pages_for_action += d.pages or 0
|
||||
elif d.type_id == 'statchg':
|
||||
for rel in d.related_that_doc(STATUSCHANGE_RELATIONS):
|
||||
pages_for_action += rel.document.pages or 0
|
||||
elif d.type_id == 'conflrev':
|
||||
for rel in d.related_that_doc('conflrev'):
|
||||
pages_for_action += rel.document.pages or 0
|
||||
else:
|
||||
pass
|
||||
|
||||
related_pages = 0
|
||||
for d in for_approval-set(drafts):
|
||||
if d.type_id == 'statchg':
|
||||
for rel in d.related_that_doc(STATUSCHANGE_RELATIONS):
|
||||
related_pages += rel.document.pages or 0
|
||||
elif d.type_id == 'conflrev':
|
||||
for rel in d.related_that_doc('conflrev'):
|
||||
related_pages += rel.document.pages or 0
|
||||
else:
|
||||
# There's really nothing to rely on to give a reading load estimate for charters
|
||||
pass
|
||||
|
||||
return TelechatPageCount(for_approval=pages_for_approval,
|
||||
for_action=pages_for_action,
|
||||
related=related_pages)
|
|
@ -40,6 +40,8 @@ import time
|
|||
import itertools
|
||||
import json
|
||||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
|
@ -55,6 +57,7 @@ from ietf.doc.utils import update_telechat, augment_events_with_revision
|
|||
from ietf.group.models import GroupMilestone
|
||||
from ietf.iesg.agenda import agenda_data, agenda_sections, fill_in_agenda_docs, get_agenda_date
|
||||
from ietf.iesg.models import TelechatDate
|
||||
from ietf.iesg.utils import telechat_page_count
|
||||
from ietf.ietfauth.utils import has_role, role_required, user_is_person
|
||||
from ietf.person.models import Person
|
||||
from ietf.doc.views_search import fill_in_search_attributes
|
||||
|
@ -92,6 +95,7 @@ def agenda_json(request, date=None):
|
|||
res = {
|
||||
"telechat-date": str(data["date"]),
|
||||
"as-of": str(datetime.datetime.utcnow()),
|
||||
"page-counts": telechat_page_count(get_agenda_date(date))._asdict(),
|
||||
"sections": {},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue