Skip to content

Commit adf2a99

Browse files
authored
ci: merge main to release (ietf-tools#6780)
ci: merge main to release
2 parents 5d06262 + 20d7e8c commit adf2a99

5 files changed

Lines changed: 67 additions & 24 deletions

File tree

ietf/doc/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ def is_downref(self):
700700

701701
if self.source.type_id == "rfc":
702702
source_lvl = self.source.std_level_id
703+
elif self.source.type_id in ["bcp","std"]:
704+
source_lvl = self.source.type_id
703705
else:
704706
source_lvl = self.source.intended_std_level_id
705707

@@ -711,6 +713,8 @@ def is_downref(self):
711713
target_lvl = 'unkn'
712714
else:
713715
target_lvl = self.target.std_level_id
716+
elif self.target.type_id in ["bcp", "std"]:
717+
target_lvl = self.target.type_id
714718
else:
715719
if not self.target.intended_std_level:
716720
target_lvl = 'unkn'

ietf/doc/tests_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ def do_fuzzy_find_documents_rfc_test(self, name):
309309
found = fuzzy_find_documents(draft.name, '22')
310310
self.assertCountEqual(found.documents, [draft],
311311
'Should find document even if rev does not exist')
312+
313+
# by rfc name mistakenly trying to provide a revision
314+
found = fuzzy_find_documents(rfc.name+"-22")
315+
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )
316+
found = fuzzy_find_documents(rfc.name,"22")
317+
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )
312318

313319

314320
def test_fuzzy_find_documents(self):

ietf/doc/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,14 +1209,15 @@ def fuzzy_find_documents(name, rev=None):
12091209

12101210
if name.startswith("rfc"):
12111211
sought_type = "rfc"
1212-
log.assertion("rev is None")
1212+
name = name.split("-")[0] # strip any noise (like a revision) at and after the first hyphen
1213+
rev = None # If someone is looking for an RFC and supplies a version, ignore it.
12131214
else:
12141215
sought_type = "draft"
12151216

12161217
# see if we can find a document using this name
12171218
docs = Document.objects.filter(name=name, type_id=sought_type)
1218-
if rev and not docs.exists():
1219-
# No document found, see if the name/rev split has been misidentified.
1219+
if sought_type == "draft" and rev and not docs.exists():
1220+
# No draft found, see if the name/rev split has been misidentified.
12201221
# Handles some special cases, like draft-ietf-tsvwg-ieee-802-11.
12211222
name = '%s-%s' % (name, rev)
12221223
docs = Document.objects.filter(name=name, type_id='draft')

ietf/group/views.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -740,23 +740,40 @@ def dependencies(request, acronym, group_type=None):
740740
source__type="draft",
741741
relationship__slug__startswith="ref",
742742
)
743-
744-
both_rfcs = Q(source__type_id="rfc", target__type_id="rfc")
745-
inactive = Q(source__states__slug__in=["expired", "repl"])
743+
rfc_or_subseries = {"rfc", "bcp", "fyi", "std"}
744+
both_rfcs = Q(source__type_id="rfc", target__type_id__in=rfc_or_subseries)
745+
pre_rfc_draft_to_rfc = Q(
746+
source__states__type="draft",
747+
source__states__slug="rfc",
748+
target__type_id__in=rfc_or_subseries,
749+
)
750+
both_pre_rfcs = Q(
751+
source__states__type="draft",
752+
source__states__slug="rfc",
753+
target__type_id="draft",
754+
target__states__type="draft",
755+
target__states__slug="rfc",
756+
)
757+
inactive = Q(
758+
source__states__type="draft",
759+
source__states__slug__in=["expired", "repl"],
760+
)
746761
attractor = Q(target__name__in=["rfc5000", "rfc5741"])
747-
removed = Q(source__states__slug__in=["auth-rm", "ietf-rm"])
762+
removed = Q(source__states__type="draft", source__states__slug__in=["auth-rm", "ietf-rm"])
748763
relations = (
749764
RelatedDocument.objects.filter(references)
750765
.exclude(both_rfcs)
766+
.exclude(pre_rfc_draft_to_rfc)
767+
.exclude(both_pre_rfcs)
751768
.exclude(inactive)
752769
.exclude(attractor)
753770
.exclude(removed)
754771
)
755772

756773
links = set()
757774
for x in relations:
758-
target_state = x.target.get_state_slug("draft")
759-
if target_state != "rfc" or x.is_downref():
775+
always_include = x.target.type_id not in rfc_or_subseries and x.target.get_state_slug("draft") != "rfc"
776+
if always_include or x.is_downref():
760777
links.add(x)
761778

762779
replacements = RelatedDocument.objects.filter(
@@ -771,13 +788,12 @@ def dependencies(request, acronym, group_type=None):
771788
graph = {
772789
"nodes": [
773790
{
774-
"id": x.name,
775-
"rfc": x.get_state("draft").slug == "rfc",
776-
"post-wg": not x.get_state("draft-iesg").slug
777-
in ["idexists", "watching", "dead"],
778-
"expired": x.get_state("draft").slug == "expired",
779-
"replaced": x.get_state("draft").slug == "repl",
780-
"group": x.group.acronym if x.group.acronym != "none" else "",
791+
"id": x.became_rfc().name if x.became_rfc() else x.name,
792+
"rfc": x.type_id == "rfc" or x.became_rfc() is not None,
793+
"post-wg": x.get_state_slug("draft-iesg") not in ["idexists", "watching", "dead"],
794+
"expired": x.get_state_slug("draft") == "expired",
795+
"replaced": x.get_state_slug("draft") == "repl",
796+
"group": x.group.acronym if x.group and x.group.acronym != "none" else "",
781797
"url": x.get_absolute_url(),
782798
"level": x.intended_std_level.name
783799
if x.intended_std_level
@@ -789,8 +805,8 @@ def dependencies(request, acronym, group_type=None):
789805
],
790806
"links": [
791807
{
792-
"source": x.source.name,
793-
"target": x.target.name,
808+
"source": x.source.became_rfc().name if x.source.became_rfc() else x.source.name,
809+
"target": x.target.became_rfc().name if x.target.became_rfc() else x.target.name,
794810
"rel": "downref" if x.is_downref() else x.relationship.slug,
795811
}
796812
for x in links

ietf/stats/views.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.conf import settings
1515
from django.contrib.auth.decorators import login_required
1616
from django.core.cache import cache
17-
from django.db.models import Count, Q
17+
from django.db.models import Count, Q, Subquery, OuterRef
1818
from django.http import HttpResponseRedirect
1919
from django.shortcuts import get_object_or_404, render
2020
from django.urls import reverse as urlreverse
@@ -34,7 +34,7 @@
3434
from ietf.person.models import Person
3535
from ietf.name.models import ReviewResultName, CountryName, DocRelationshipName, ReviewAssignmentStateName
3636
from ietf.person.name import plain_name
37-
from ietf.doc.models import Document, State, DocEvent
37+
from ietf.doc.models import Document, RelatedDocument, State, DocEvent
3838
from ietf.meeting.models import Meeting
3939
from ietf.stats.models import MeetingRegistration, CountryAlias
4040
from ietf.stats.utils import get_aliased_affiliations, get_aliased_countries, compute_hirsch_index
@@ -607,15 +607,31 @@ def build_document_stats_url(stats_type_override=Ellipsis, get_overrides=None):
607607

608608
doc_years = defaultdict(set)
609609

610-
docevent_qs = DocEvent.objects.filter(
610+
draftevent_qs = DocEvent.objects.filter(
611611
doc__type="draft",
612-
type__in=["published_rfc", "new_revision"],
613-
).values_list("doc", "time").order_by("doc")
612+
type = "new_revision",
613+
).values_list("doc","time").order_by("doc")
614614

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

619+
rfcevent_qs = (
620+
DocEvent.objects.filter(doc__type="rfc", type="published_rfc")
621+
.annotate(
622+
draft=Subquery(
623+
RelatedDocument.objects.filter(
624+
target=OuterRef("doc__pk"), relationship_id="became_rfc"
625+
).values_list("source", flat=True)[:1]
626+
)
627+
)
628+
.values_list("draft", "time")
629+
.order_by("draft")
630+
)
631+
632+
for doc_id, time in rfcevent_qs.iterator():
633+
doc_years[doc_id].add(time.astimezone(RPC_TZINFO).year)
634+
619635
person_qs = Person.objects.filter(person_filters)
620636

621637
if document_type == "rfc":

0 commit comments

Comments
 (0)