-
Notifications
You must be signed in to change notification settings - Fork 378
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: Include missing related drafts in IPR searches #7836
Changes from 1 commit
1147c4f
f643b1c
62a52ee
195f8cb
6e4c803
a4fc313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -689,18 +689,41 @@ def search(request): | |
if len(start) == 1: | ||
first = start[0] | ||
doc = first | ||
docs_related = related_docs(first, reverse_relationship=()) | ||
drafts_related = [ | ||
d2 | ||
for d1 in docs_related | ||
for d2 in related_docs(d1, relationship=()) | ||
if d2 is not None | ||
] | ||
docs = list(set(docs_related + drafts_related)) | ||
iprs = iprs_from_docs(docs,states=states) | ||
docs = set([first]) | ||
docs.update( | ||
related_docs( | ||
first, relationship=("replaces", "obs"), reverse_relationship=() | ||
) | ||
) | ||
docs.update( | ||
set( | ||
[ | ||
draft | ||
for drafts in [ | ||
related_docs( | ||
d, relationship=(), reverse_relationship=("became_rfc",) | ||
) | ||
for d in docs | ||
] | ||
for draft in drafts | ||
] | ||
) | ||
) | ||
docs.discard(None) | ||
docs = sorted( | ||
docs, | ||
key=lambda d: ( | ||
d.rfc_number if d.rfc_number is not None else 0, | ||
d.became_rfc().rfc_number if d.became_rfc() else 0, | ||
), | ||
reverse=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. Food for thought (not requesting a change here) - we can even do something like key=lambda d: (
d == first, # to ensure that the doc selected will always be first (untested)
# the rest...
) The expression will return a assert isinstance(True, int) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think >>> False < True
True There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We have assert sorted([False, True], reverse=True) == [True, False] Anyway, I'll leave the existing code as-is, leaving the template to handle that logic for now. |
||
) | ||
iprs = iprs_from_docs(docs, states=states) | ||
template = "ipr/search_doc_result.html" | ||
updated_docs = related_docs(first, ('updates',)) | ||
related_iprs = list(set(iprs_from_docs(updated_docs, states=states)) - set(iprs)) | ||
updated_docs = related_docs(first, ("updates",)) | ||
related_iprs = list( | ||
set(iprs_from_docs(updated_docs, states=states)) - set(iprs) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: Formatting changes can be done in a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran black on the unit. I could have done it in a separate commit. |
||
# multiple matches, select just one | ||
elif start: | ||
docs = start | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong preference here, but I personally find it easier to read when
for
s are kept flat like below.Let it be a team decision though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be whatever Black style says, which I think is what you suggest but not certain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now that I'm at a keyboard I see that this is more about the brackets than about the styling per se so appealing to Black isn't quite enough...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, what's there is what black produced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I wasn't referring to formatting style - sorry for the confusion. It was more about whether the new code is actually more readable despite having one more
for
in the expression. My opinion is that it isn't.Anyway, I'm okay with either as long as you're happy with the logic itself.