Skip to content

Commit ef99ffe

Browse files
authored
fix: correct RFC count in the activity report. fixes #9140 (#9178)
1 parent eba6191 commit ef99ffe

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

ietf/meeting/tests_utils.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,58 @@
1212
from django.http import HttpResponse, JsonResponse
1313
from ietf.meeting.factories import MeetingFactory, RegistrationFactory, RegistrationTicketFactory
1414
from ietf.meeting.models import Registration
15-
from ietf.meeting.utils import (process_single_registration,
16-
get_registration_data, sync_registration_data, fetch_attendance_from_meetings)
15+
from ietf.meeting.utils import (
16+
process_single_registration,
17+
get_registration_data,
18+
sync_registration_data,
19+
fetch_attendance_from_meetings,
20+
get_activity_stats
21+
)
1722
from ietf.nomcom.models import Volunteer
1823
from ietf.nomcom.factories import NomComFactory, nomcom_kwargs_for_year
1924
from ietf.person.factories import PersonFactory
2025
from ietf.utils.test_utils import TestCase
26+
from ietf.meeting.test_data import make_meeting_test_data
27+
from ietf.doc.factories import NewRevisionDocEventFactory, DocEventFactory
2128

2229

2330
class JsonResponseWithJson(JsonResponse):
2431
def json(self):
2532
return json.loads(self.content)
2633

2734

35+
class ActivityStatsTests(TestCase):
36+
37+
def test_activity_stats(self):
38+
utc = datetime.timezone.utc
39+
make_meeting_test_data()
40+
sdate = datetime.date(2016,4,3)
41+
edate = datetime.date(2016,7,14)
42+
MeetingFactory(type_id='ietf', date=sdate, number="96")
43+
MeetingFactory(type_id='ietf', date=edate, number="97")
44+
45+
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,5,12,0,0,0,tzinfo=utc))
46+
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,6,12,0,0,0,tzinfo=utc))
47+
NewRevisionDocEventFactory(time=datetime.datetime(2016,4,7,12,0,0,0,tzinfo=utc))
48+
49+
NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,12,0,0,0,tzinfo=utc))
50+
NewRevisionDocEventFactory(time=datetime.datetime(2016,6,30,13,0,0,0,tzinfo=utc))
51+
52+
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))
53+
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))
54+
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))
55+
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))
56+
57+
data = get_activity_stats(sdate, edate)
58+
self.assertEqual(data['new_drafts_count'], len(data['new_docs']))
59+
self.assertEqual(data['ffw_new_count'], 2)
60+
self.assertEqual(data['ffw_new_percent'], '40%')
61+
rfc_count = 0
62+
for c in data['counts']:
63+
rfc_count += data['counts'].get(c)
64+
self.assertEqual(rfc_count, len(data['rfcs']))
65+
66+
2867
class GetRegistrationsTests(TestCase):
2968

3069
@patch('ietf.meeting.utils.requests.get')

ietf/meeting/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -949,13 +949,14 @@ def get_activity_stats(sdate, edate):
949949
data['ffw_update_count'] = ffw_update_count
950950
data['ffw_update_percent'] = ffw_update_percent
951951

952-
rfcs = events.filter(type='published_rfc')
953-
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__intended_std_level')
954-
955-
data['counts'] = {'std': rfcs.filter(doc__intended_std_level__in=('ps', 'ds', 'std')).count(),
956-
'bcp': rfcs.filter(doc__intended_std_level='bcp').count(),
957-
'exp': rfcs.filter(doc__intended_std_level='exp').count(),
958-
'inf': rfcs.filter(doc__intended_std_level='inf').count()}
952+
rfcs_events = DocEvent.objects.filter(doc__type='rfc', time__gte=sdatetime, time__lt=edatetime)
953+
rfcs = rfcs_events.filter(type='published_rfc')
954+
data['rfcs'] = rfcs.select_related('doc').select_related('doc__group').select_related('doc__std_level')
955+
956+
data['counts'] = {'std': rfcs.filter(doc__std_level__in=('ps', 'ds', 'std')).count(),
957+
'bcp': rfcs.filter(doc__std_level='bcp').count(),
958+
'exp': rfcs.filter(doc__std_level='exp').count(),
959+
'inf': rfcs.filter(doc__std_level='inf').count()}
959960

960961
data['new_groups'] = Group.objects.filter(
961962
type='wg',

ietf/templates/meeting/activity_report.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ <h3 class="mt-3">{{ rfcs.count }} RFCs published this period</h3>
4040
<th scope="col" data-sort="title">Title</th>
4141
</tr>
4242
</thead>
43-
{% if rfcs %}
43+
{% if rfcs|length > 0 %}
4444
<tbody>
4545
{% for rfc in rfcs %}
4646
<tr>
4747
<td class="text-nowrap">
4848
<a href="{{ rfc.doc.get_absolute_url }}">{{ rfc.doc.name|prettystdname }}</a>
4949
</td>
50-
<td class="text-nowrap">{{ rfc.doc.intended_std_level.name }}</td>
50+
<td class="text-nowrap">{{ rfc.doc.std_level.name }}</td>
5151
<td>
5252
<a href="{{ rfc.doc.group.about_url }}">{{ rfc.doc.group.acronym }}</a>
5353
</td>

0 commit comments

Comments
 (0)