Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gather interesting years for stats accounting for published rfcs #6776

Merged
merged 1 commit into from
Dec 13, 2023
Merged
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
28 changes: 22 additions & 6 deletions ietf/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.cache import cache
from django.db.models import Count, Q
from django.db.models import Count, Q, Subquery, OuterRef
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse as urlreverse
Expand All @@ -34,7 +34,7 @@
from ietf.person.models import Person
from ietf.name.models import ReviewResultName, CountryName, DocRelationshipName, ReviewAssignmentStateName
from ietf.person.name import plain_name
from ietf.doc.models import Document, State, DocEvent
from ietf.doc.models import Document, RelatedDocument, State, DocEvent
from ietf.meeting.models import Meeting
from ietf.stats.models import MeetingRegistration, CountryAlias
from ietf.stats.utils import get_aliased_affiliations, get_aliased_countries, compute_hirsch_index
Expand Down Expand Up @@ -607,15 +607,31 @@ def build_document_stats_url(stats_type_override=Ellipsis, get_overrides=None):

doc_years = defaultdict(set)

docevent_qs = DocEvent.objects.filter(
draftevent_qs = DocEvent.objects.filter(
doc__type="draft",
type__in=["published_rfc", "new_revision"],
).values_list("doc", "time").order_by("doc")
type = "new_revision",
).values_list("doc","time").order_by("doc")

for doc_id, time in docevent_qs.iterator():
for doc_id, time in draftevent_qs.iterator():
# RPC_TZINFO is used to match the timezone handling in Document.pub_date()
doc_years[doc_id].add(time.astimezone(RPC_TZINFO).year)

rfcevent_qs = (
DocEvent.objects.filter(doc__type="rfc", type="published_rfc")
.annotate(
draft=Subquery(
RelatedDocument.objects.filter(
target=OuterRef("doc__pk"), relationship_id="became_rfc"
).values_list("source", flat=True)[:1]
)
)
.values_list("draft", "time")
.order_by("draft")
)

for doc_id, time in rfcevent_qs.iterator():
doc_years[doc_id].add(time.astimezone(RPC_TZINFO).year)

person_qs = Person.objects.filter(person_filters)

if document_type == "rfc":
Expand Down
Loading