|
| 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) |
0 commit comments