Skip to content

Commit

Permalink
feat: total ids, pre-pubreq counts and pages left to ballot on on the…
Browse files Browse the repository at this point in the history
… AD dashboard (#7813)

* feat: Total ids on IESG dashboard

* IESG I-D code comments

* Using Robert's query forIESG dashboard total_ids

* Hiding columns in later IESG Dashboard tables

* Changing IESG dashboard var name to match column table

* Updating IESG pre_pubreqquery

* IESG dashboard prepub req safeParser and graphs

* IESG dashboard fixing Playwright API usage

* IESG dashboard fixing Playwright API usage (2)

* Updating .gitignore for /geckodriver.log

* IESG ad test title

* feat: pages left to ballot on [WIP]

* Adding geckodriver.log to gitignore

* [WIP] pages left to ballot on

* integrating pages left to ballot on WIP

* Tests for ad pages remaining

* Setting states to test ballot items

* refactor ad_pages_left_to_ballot_on count logic

* WIP tests for pages left to ballot on

* chore: remove whitespace change

* fix: look into the BallotPositionDocEventObject

* chore: remove prints

* fix: restructure test

* style: fix js code styling

* fix: only show graph for ADs/Secretariat

---------

Co-authored-by: Matthew Holloway <Matthew Holloway>
Co-authored-by: holloway <[email protected]>
Co-authored-by: Nicolas Giard <[email protected]>
Co-authored-by: Matthew Holloway <[email protected]>
  • Loading branch information
4 people authored Sep 5, 2024
1 parent 2a6fd3e commit cb25831
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ datatracker.sublime-workspace
/docker/docker-compose.extend-custom.yml
/env
/ghostdriver.log
/geckodriver.log
/htmlcov
/ietf/static/dist-neue
/latest-coverage.json
Expand Down
23 changes: 23 additions & 0 deletions ietf/doc/views_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,29 @@ def _state_to_doc_type(state):
)
ad.buckets = copy.deepcopy(bucket_template)

# https://github.com/ietf-tools/datatracker/issues/4577
docs_via_group_ad = Document.objects.exclude(
group__acronym="none"
).filter(
group__role__name="ad",
group__role__person=ad
).filter(
states__type="draft-stream-ietf",
states__slug__in=["wg-doc","wg-lc","waiting-for-implementation","chair-w","writeupw"]
)

doc_for_ad = Document.objects.filter(ad=ad)

ad.pre_pubreq = (docs_via_group_ad | doc_for_ad).filter(
type="draft"
).filter(
states__type="draft",
states__slug="active"
).filter(
states__type="draft-iesg",
states__slug="idexists"
).distinct().count()

for doc in Document.objects.exclude(type_id="rfc").filter(ad=ad):
dt = doc_type(doc)
state = doc_state(doc)
Expand Down
68 changes: 64 additions & 4 deletions ietf/iesg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from ietf.doc.models import DocEvent, BallotPositionDocEvent, TelechatDocEvent
from ietf.doc.models import Document, State, RelatedDocument
from ietf.doc.factories import WgDraftFactory, IndividualDraftFactory, ConflictReviewFactory, BaseDocumentFactory, CharterFactory, WgRfcFactory, IndividualRfcFactory
from ietf.doc.factories import BallotDocEventFactory, BallotPositionDocEventFactory, TelechatDocEventFactory, WgDraftFactory, IndividualDraftFactory, ConflictReviewFactory, BaseDocumentFactory, CharterFactory, WgRfcFactory, IndividualRfcFactory
from ietf.doc.utils import create_ballot_if_not_open
from ietf.group.factories import RoleFactory, GroupFactory, DatedGroupMilestoneFactory, DatelessGroupMilestoneFactory
from ietf.group.models import Group, GroupMilestone, Role
Expand All @@ -30,7 +30,6 @@
from ietf.iesg.factories import IESGMgmtItemFactory, TelechatAgendaContentFactory
from ietf.utils.timezone import date_today, DEADLINE_TZINFO


class IESGTests(TestCase):
def test_feed(self):
draft = WgDraftFactory(states=[('draft','active'),('draft-iesg','iesg-eva')],ad=Person.objects.get(user__username='ad'))
Expand Down Expand Up @@ -509,12 +508,13 @@ def test_agenda_documents_txt(self):
def test_agenda_documents(self):
url = urlreverse("ietf.iesg.views.agenda_documents")
r = self.client.get(url)

self.assertEqual(r.status_code, 200)

for k, d in self.telechat_docs.items():
self.assertContains(r, d.name, msg_prefix="%s '%s' not in response" % (k, d.name, ))
self.assertContains(r, d.title, msg_prefix="%s '%s' title not in response" % (k, d.title, ))

self.assertContains(r, d.title, msg_prefix="%s '%s' not in response" % (k, d.title, ))
def test_past_documents(self):
url = urlreverse("ietf.iesg.views.past_documents")
# We haven't put any documents on past telechats, so this should be empty
Expand Down Expand Up @@ -589,6 +589,66 @@ def test_admin_change(self):
draft = Document.objects.get(name="draft-ietf-mars-test")
self.assertEqual(draft.telechat_date(),today)

class IESGAgendaTelechatPagesTests(TestCase):
def setUp(self):
super().setUp()
# make_immutable_test_data made a set of future telechats - only need one
# We'll take the "next" one
self.telechat_date = get_agenda_date()
# make_immutable_test_data made and area with only one ad - give it another
ad = Person.objects.get(user__username="ad")
adrole = Role.objects.get(person=ad, name="ad")
ad2 = RoleFactory(group=adrole.group, name_id="ad").person
self.ads=[ad,ad2]

# Make some drafts
docs = [
WgDraftFactory(pages=2, states=[('draft-iesg','iesg-eva'),]),
IndividualDraftFactory(pages=20, states=[('draft-iesg','iesg-eva'),]),
WgDraftFactory(pages=200, states=[('draft-iesg','iesg-eva'),]),
]
# Put them on the telechat
for doc in docs:
TelechatDocEventFactory(doc=doc, telechat_date=self.telechat_date)
# Give them ballots
ballots = [BallotDocEventFactory(doc=doc) for doc in docs]

# Give the "ad" Area-Director a discuss on one
BallotPositionDocEventFactory(balloter=ad, doc=docs[0], pos_id="discuss", ballot=ballots[0])
# and a "norecord" position on another
BallotPositionDocEventFactory(balloter=ad, doc=docs[1], pos_id="norecord", ballot=ballots[1])
# Now "ad" should have 220 pages left to ballot on.
# Every other ad should have 222 pages left to ballot on.

def test_ad_pages_left_to_ballot_on(self):
url = urlreverse("ietf.iesg.views.agenda_documents")

# A non-AD user won't get "pages left"
response = self.client.get(url)
telechat = response.context["telechats"][0]
self.assertEqual(telechat["date"], self.telechat_date)
self.assertEqual(telechat["ad_pages_left_to_ballot_on"],0)
self.assertNotContains(response,"pages left to ballot on")

username=self.ads[0].user.username
self.assertTrue(self.client.login(username=username, password=f"{username}+password"))

response = self.client.get(url)
telechat = response.context["telechats"][0]
self.assertEqual(telechat["ad_pages_left_to_ballot_on"],220)
self.assertContains(response,"220 pages left to ballot on")

self.client.logout()
username=self.ads[1].user.username
self.assertTrue(self.client.login(username=username, password=f"{username}+password"))

response = self.client.get(url)
telechat = response.context["telechats"][0]
self.assertEqual(telechat["ad_pages_left_to_ballot_on"],222)




class RescheduleOnAgendaTests(TestCase):
def test_reschedule(self):
draft = WgDraftFactory()
Expand Down
22 changes: 17 additions & 5 deletions ietf/iesg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from ietf.iesg.agenda import get_doc_section


TelechatPageCount = namedtuple('TelechatPageCount',['for_approval','for_action','related'])
TelechatPageCount = namedtuple('TelechatPageCount',['for_approval','for_action','related','ad_pages_left_to_ballot_on'])

def telechat_page_count(date=None, docs=None):
def telechat_page_count(date=None, docs=None, ad=None):
if not date and not docs:
return TelechatPageCount(0, 0, 0)
return TelechatPageCount(0, 0, 0, 0)

if not docs:
candidates = Document.objects.filter(docevent__telechatdocevent__telechat_date=date).distinct()
Expand All @@ -24,7 +24,18 @@ def telechat_page_count(date=None, docs=None):

drafts = [d for d in for_approval if d.type_id == 'draft']

pages_for_approval = sum([d.pages or 0 for d in drafts])
ad_pages_left_to_ballot_on = 0
pages_for_approval = 0

for draft in drafts:
pages_for_approval += draft.pages or 0
if ad:
ballot = draft.active_ballot()
if ballot:
positions = ballot.active_balloter_positions()
ad_position = positions[ad]
if ad_position is None or ad_position.pos_id == "norecord":
ad_pages_left_to_ballot_on += draft.pages or 0

pages_for_action = 0
for d in for_action:
Expand Down Expand Up @@ -53,4 +64,5 @@ def telechat_page_count(date=None, docs=None):

return TelechatPageCount(for_approval=pages_for_approval,
for_action=pages_for_action,
related=related_pages)
related=related_pages,
ad_pages_left_to_ballot_on=ad_pages_left_to_ballot_on)
8 changes: 6 additions & 2 deletions ietf/iesg/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ def handle_reschedule_form(request, doc, dates, status):
return form

def agenda_documents(request):
ad = request.user.person if has_role(request.user, "Area Director") else None

dates = list(TelechatDate.objects.active().order_by('date').values_list("date", flat=True)[:4])

docs_by_date = dict((d, []) for d in dates)
Expand Down Expand Up @@ -389,11 +391,13 @@ def agenda_documents(request):
# the search_result_row view to display them (which expects them)
fill_in_document_table_attributes(docs_by_date[date], have_telechat_date=True)
fill_in_agenda_docs(date, sections, docs_by_date[date])
pages = telechat_page_count(docs=docs_by_date[date]).for_approval

page_count = telechat_page_count(docs=docs_by_date[date], ad=ad)
pages = page_count.for_approval

telechats.append({
"date": date,
"pages": pages,
"ad_pages_left_to_ballot_on": page_count.ad_pages_left_to_ballot_on,
"sections": sorted((num, section) for num, section in sections.items()
if "2" <= num < "5")
})
Expand Down
Loading

0 comments on commit cb25831

Please sign in to comment.