fix: Update group dependencies for new rfc model (#6773)

* fix: Avoid accessing slug when state is None

* fix: ignore pre-rfc drafts as rfc-to-rfc references

* fix: also ignore pre-rfc to pre-rfc refs

* chore: remove breakpoint

* fix: ignore subseries non-downrefs

* fix: label nodes as RFCS when possible

* fix: get "rfc" flag right

* chore: Remove comment, answer seems to be "no"

* refactor: Specify state type; drop redundant source doc type check

We're only admitting source__type="draft", so
no need to check it again in filter queries

* refactor: Specify state type in old code
This commit is contained in:
Jennifer Richards 2023-12-14 11:29:55 -04:00 committed by GitHub
parent 6ccf9080b4
commit 6083205cc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -740,14 +740,31 @@ def dependencies(request, acronym, group_type=None):
source__type="draft", source__type="draft",
relationship__slug__startswith="ref", relationship__slug__startswith="ref",
) )
rfc_or_subseries = {"rfc", "bcp", "fyi", "std"}
both_rfcs = Q(source__type_id="rfc", target__type_id="rfc") both_rfcs = Q(source__type_id="rfc", target__type_id__in=rfc_or_subseries)
inactive = Q(source__states__slug__in=["expired", "repl"]) pre_rfc_draft_to_rfc = Q(
source__states__type="draft",
source__states__slug="rfc",
target__type_id__in=rfc_or_subseries,
)
both_pre_rfcs = Q(
source__states__type="draft",
source__states__slug="rfc",
target__type_id="draft",
target__states__type="draft",
target__states__slug="rfc",
)
inactive = Q(
source__states__type="draft",
source__states__slug__in=["expired", "repl"],
)
attractor = Q(target__name__in=["rfc5000", "rfc5741"]) attractor = Q(target__name__in=["rfc5000", "rfc5741"])
removed = Q(source__states__slug__in=["auth-rm", "ietf-rm"]) removed = Q(source__states__type="draft", source__states__slug__in=["auth-rm", "ietf-rm"])
relations = ( relations = (
RelatedDocument.objects.filter(references) RelatedDocument.objects.filter(references)
.exclude(both_rfcs) .exclude(both_rfcs)
.exclude(pre_rfc_draft_to_rfc)
.exclude(both_pre_rfcs)
.exclude(inactive) .exclude(inactive)
.exclude(attractor) .exclude(attractor)
.exclude(removed) .exclude(removed)
@ -755,8 +772,8 @@ def dependencies(request, acronym, group_type=None):
links = set() links = set()
for x in relations: for x in relations:
target_state = x.target.get_state_slug("draft") always_include = x.target.type_id not in rfc_or_subseries and x.target.get_state_slug("draft") != "rfc"
if target_state != "rfc" or x.is_downref(): if always_include or x.is_downref():
links.add(x) links.add(x)
replacements = RelatedDocument.objects.filter( replacements = RelatedDocument.objects.filter(
@ -771,13 +788,12 @@ def dependencies(request, acronym, group_type=None):
graph = { graph = {
"nodes": [ "nodes": [
{ {
"id": x.name, "id": x.became_rfc().name if x.became_rfc() else x.name,
"rfc": x.get_state("draft").slug == "rfc", "rfc": x.type_id == "rfc" or x.became_rfc() is not None,
"post-wg": not x.get_state("draft-iesg").slug "post-wg": x.get_state_slug("draft-iesg") not in ["idexists", "watching", "dead"],
in ["idexists", "watching", "dead"], "expired": x.get_state_slug("draft") == "expired",
"expired": x.get_state("draft").slug == "expired", "replaced": x.get_state_slug("draft") == "repl",
"replaced": x.get_state("draft").slug == "repl", "group": x.group.acronym if x.group and x.group.acronym != "none" else "",
"group": x.group.acronym if x.group.acronym != "none" else "",
"url": x.get_absolute_url(), "url": x.get_absolute_url(),
"level": x.intended_std_level.name "level": x.intended_std_level.name
if x.intended_std_level if x.intended_std_level
@ -789,8 +805,8 @@ def dependencies(request, acronym, group_type=None):
], ],
"links": [ "links": [
{ {
"source": x.source.name, "source": x.source.became_rfc().name if x.source.became_rfc() else x.source.name,
"target": x.target.name, "target": x.target.became_rfc().name if x.target.became_rfc() else x.target.name,
"rel": "downref" if x.is_downref() else x.relationship.slug, "rel": "downref" if x.is_downref() else x.relationship.slug,
} }
for x in links for x in links