Skip to content

Commit b66dffe

Browse files
committed
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 67f0234
2 parents f50636c + 67f0234 commit b66dffe

5 files changed

Lines changed: 59 additions & 12 deletions

File tree

ietf/doc/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django import forms
44

55
from ietf.iesg.models import TelechatDate
6-
from ietf.doc.models import Document
6+
from ietf.iesg.utils import telechat_page_count
77

88
class TelechatForm(forms.Form):
99
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 @@ def __init__(self, *args, **kwargs):
2020
self.page_count = {}
2121
choice_display = {}
2222
for d in dates:
23-
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])
23+
self.page_count[d] = telechat_page_count(d).for_approval
2424
choice_display[d] = '%s (%s pages)' % (d.strftime("%Y-%m-%d"),self.page_count[d])
2525
self.fields['telechat_date'].choices = [("", "(not on agenda)")] + [(d, choice_display[d]) for d in dates]
2626

ietf/iesg/agenda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_doc_section(doc):
3838
s += ".3"
3939
else:
4040
s += ".2"
41-
if doc.get_state_slug() != "rfc" and doc.get_state_slug('draft-iesg') not in ("lc", "writeupw", "goaheadw", "iesg-eva", "defer"):
41+
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"):
4242
s += ".3"
4343
elif doc.returning_item():
4444
s += ".2"
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
from django import template
22

3+
from ietf.iesg.utils import telechat_page_count as page_counter
4+
35
register = template.Library()
46

57
@register.filter
68
def telechat_page_count(telechat):
7-
page_count = 0
8-
for num, section in telechat['sections']:
9-
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',):
10-
for doc in section['docs']:
11-
page_count += getattr(doc,'pages',0)
12-
return page_count
13-
14-
# An alternate implementation:
15-
# sum([doc.pages for doc in Document.objects.filter(docevent__telechatdocevent__telechat_date=d,type='draft').distict() if doc.telechat_date()==d])
9+
return page_counter(telechat['date']).for_approval

ietf/iesg/utils.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from collections import namedtuple
2+
3+
from ietf.doc.models import Document, TelechatDocEvent, STATUSCHANGE_RELATIONS
4+
from ietf.iesg.agenda import get_doc_section
5+
6+
TelechatPageCount = namedtuple('TelechatPageCount',['for_approval','for_action','related'])
7+
8+
def telechat_page_count(date):
9+
10+
candidates = Document.objects.filter(docevent__telechatdocevent__telechat_date=date).distinct()
11+
12+
docs = [ doc for doc in candidates if doc.latest_event(TelechatDocEvent,type='scheduled_for_telechat').telechat_date==date ]
13+
14+
for_action =[d for d in docs if get_doc_section(d).endswith('.3')]
15+
16+
for_approval = set(docs)-set(for_action)
17+
18+
drafts = [d for d in for_approval if d.type_id == 'draft']
19+
20+
pages_for_approval = sum([d.pages or 0 for d in drafts])
21+
22+
pages_for_action = 0
23+
for d in for_action:
24+
if d.type_id == 'draft':
25+
pages_for_action += d.pages or 0
26+
elif d.type_id == 'statchg':
27+
for rel in d.related_that_doc(STATUSCHANGE_RELATIONS):
28+
pages_for_action += rel.document.pages or 0
29+
elif d.type_id == 'conflrev':
30+
for rel in d.related_that_doc('conflrev'):
31+
pages_for_action += rel.document.pages or 0
32+
else:
33+
pass
34+
35+
related_pages = 0
36+
for d in for_approval-set(drafts):
37+
if d.type_id == 'statchg':
38+
for rel in d.related_that_doc(STATUSCHANGE_RELATIONS):
39+
related_pages += rel.document.pages or 0
40+
elif d.type_id == 'conflrev':
41+
for rel in d.related_that_doc('conflrev'):
42+
related_pages += rel.document.pages or 0
43+
else:
44+
# There's really nothing to rely on to give a reading load estimate for charters
45+
pass
46+
47+
return TelechatPageCount(for_approval=pages_for_approval,
48+
for_action=pages_for_action,
49+
related=related_pages)

ietf/iesg/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import itertools
4141
import json
4242

43+
import debug # pyflakes:ignore
44+
4345

4446
from django import forms
4547
from django.conf import settings
@@ -55,6 +57,7 @@
5557
from ietf.group.models import GroupMilestone
5658
from ietf.iesg.agenda import agenda_data, agenda_sections, fill_in_agenda_docs, get_agenda_date
5759
from ietf.iesg.models import TelechatDate
60+
from ietf.iesg.utils import telechat_page_count
5861
from ietf.ietfauth.utils import has_role, role_required, user_is_person
5962
from ietf.person.models import Person
6063
from ietf.doc.views_search import fill_in_search_attributes
@@ -92,6 +95,7 @@ def agenda_json(request, date=None):
9295
res = {
9396
"telechat-date": str(data["date"]),
9497
"as-of": str(datetime.datetime.utcnow()),
98+
"page-counts": telechat_page_count(get_agenda_date(date))._asdict(),
9599
"sections": {},
96100
}
97101

0 commit comments

Comments
 (0)