Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions ietf/meeting/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,58 @@
from django.http import HttpResponse, JsonResponse
from ietf.meeting.factories import MeetingFactory, RegistrationFactory, RegistrationTicketFactory
from ietf.meeting.models import Registration
from ietf.meeting.utils import (process_single_registration,
get_registration_data, sync_registration_data, fetch_attendance_from_meetings)
from ietf.meeting.utils import (
process_single_registration,
get_registration_data,
sync_registration_data,
fetch_attendance_from_meetings,
get_activity_stats
)
from ietf.nomcom.models import Volunteer
from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year
from ietf.person.factories import PersonFactory
from ietf.utils.test_utils import TestCase
from ietf.meeting.test_data import make_meeting_test_data
from ietf.doc.factories import NewRevisionDocEventFactory, DocEventFactory


class JsonResponseWithJson(JsonResponse):
def json(self):
return json.loads(self.content)


class ActivityStatsTests(TestCase):

def test_activity_stats(self):
utc = datetime.timezone.utc
make_meeting_test_data()
sdate = datetime.date(2016,4,3)
edate = datetime.date(2016,7,14)
MeetingFactory(type_id='ietf', date=sdate, number="96")
MeetingFactory(type_id='ietf', date=edate, number="97")

NewRevisionDocEventFactory(time=datetime.datetime(2016,4,5,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,6,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,7,12,0,0,0,tzinfo=utc))

NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,12,0,0,0,tzinfo=utc))
NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,13,0,0,0,tzinfo=utc))

DocEventFactory(doc__std_level_id="ps", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,5,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="bcp", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,6,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="inf", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,7,12,0,0,0,tzinfo=utc))
DocEventFactory(doc__std_level_id="exp", doc__type_id="rfc", type="published_rfc", time=datetime.datetime(2016,4,8,12,0,0,0,tzinfo=utc))

data = get_activity_stats(sdate, edate)
self.assertEqual(data['new_drafts_count'], len(data['new_docs']))
self.assertEqual(data['ffw_new_count'], 2)
self.assertEqual(data['ffw_new_percent'], '40%')
rfc_count = 0
for c in data['counts']:
rfc_count += data['counts'].get(c)
self.assertEqual(rfc_count, len(data['rfcs']))


class GetRegistrationsTests(TestCase):

@patch('ietf.meeting.utils.requests.get')
Expand Down
15 changes: 8 additions & 7 deletions ietf/meeting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,13 +949,14 @@ def get_activity_stats(sdate, edate):
data['ffw_update_count'] = ffw_update_count
data['ffw_update_percent'] = ffw_update_percent

rfcs = events.filter(type='published_rfc')
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__intended_std_level')

data['counts'] = {'std': rfcs.filter(doc__intended_std_level__in=('ps', 'ds', 'std')).count(),
'bcp': rfcs.filter(doc__intended_std_level='bcp').count(),
'exp': rfcs.filter(doc__intended_std_level='exp').count(),
'inf': rfcs.filter(doc__intended_std_level='inf').count()}
rfcs_events = DocEvent.objects.filter(doc__type='rfc', time__gte=sdatetime, time__lt=edatetime)
rfcs = rfcs_events.filter(type='published_rfc')
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__std_level')

data['counts'] = {'std': rfcs.filter(doc__std_level__in=('ps', 'ds', 'std')).count(),
'bcp': rfcs.filter(doc__std_level='bcp').count(),
'exp': rfcs.filter(doc__std_level='exp').count(),
'inf': rfcs.filter(doc__std_level='inf').count()}

data['new_groups'] = Group.objects.filter(
type='wg',
Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/meeting/activity_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ <h3 class="mt-3">{{ rfcs.count }} RFCs published this period</h3>
<th scope="col" data-sort="title">Title</th>
</tr>
</thead>
{% if rfcs %}
{% if rfcs|length > 0 %}
<tbody>
{% for rfc in rfcs %}
<tr>
<td class="text-nowrap">
<a href="{{ rfc.doc.get_absolute_url }}">{{ rfc.doc.name|prettystdname }}</a>
</td>
<td class="text-nowrap">{{ rfc.doc.intended_std_level.name }}</td>
<td class="text-nowrap">{{ rfc.doc.std_level.name }}</td>
<td>
<a href="{{ rfc.doc.group.about_url }}">{{ rfc.doc.group.acronym }}</a>
</td>
Expand Down
Loading