Skip to content

Conversation

elear
Copy link
Contributor

@elear elear commented Oct 7, 2025

WARNING

Eliot is playing with code he may not understand.

Not quite sure how to test this in a sandbox, but happy to learn.

Intent

The intent is to sort he list of RFCs that appear in the "obsoleted by" and "updated by" lists. This makes it easier to spot RFCs in long lists, like that of RFC 2026, for instance.

Method

Register a new function "sort" and then invoke it in the template.

Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.86%. Comparing base (8fbbc55) to head (cd14db4).

Files with missing lines Patch % Lines
ietf/doc/templatetags/ietf_filters.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9677      +/-   ##
==========================================
- Coverage   88.87%   88.86%   -0.01%     
==========================================
  Files         319      319              
  Lines       41925    41928       +3     
==========================================
+ Hits        37260    37261       +1     
- Misses       4665     4667       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Right you are.  Doh!

Co-authored-by: Jennifer Richards <[email protected]>
@elear elear changed the title add a sort filter for django for the lisdexylic of us (like me) feat: add a sort filter for django for the lisdexylic of us (like me) Oct 8, 2025
@elear
Copy link
Contributor Author

elear commented Oct 8, 2025

@jennifer-richards I also don't know if this is the only place that a change needs to be made.

@rjsparks
Copy link
Member

rjsparks commented Oct 8, 2025

There's more that would need to happen I think. The comparisons need to operate on rfc numbers. The sort is probably more easily done in the view rather than the template, and the work needs to affect both this view and the /doc/html view.

@elear
Copy link
Contributor Author

elear commented Oct 9, 2025

@rjsparks there is fill_in_document_table_attributes in doc/utils_search.py. That seems to be where these values get filled in. One could add a second loop after this code:

    for rel in xed_by:
        d = doc_dict[rel.target.id]
        if rel.relationship_id == "obs":
            d.obsoleted_by_list.append(rel.source)
        elif rel.relationship_id == "updates":
            d.updated_by_list.append(rel.source)

Is that what you are referring to?

@rjsparks
Copy link
Member

rjsparks commented Oct 9, 2025

Yes, and it's only a couple of sort statements that need to be added, and I think we'll need to pass an explicit definition of the sort key to the sorting function (to pull the rfc number out of the doc object as an integer).

I'd also look for a similar place that gathers updates and obsoletes.

@elear
Copy link
Contributor Author

elear commented Oct 9, 2025

If that doc list is strings, of "rfc1234", then a lexical sort should be fine, right?

It seems to me like we are looking at something like this:

for d in doc_dict.keys():
        doc_dict[d].obsoleted_by_list.sort() # lexical
        doc_dict[d].updated_by_list.sort()

This presumes that doc_dict doesn't include all RFCs/drafts. Otherwise we have to go through the same game as above.

@jennifer-richards
Copy link
Member

If that doc list is strings, of "rfc1234", then a lexical sort should be fine, right?

The rfc numbers don't have leading zeros, so lexical sort won't match numerical sort.

@rjsparks
Copy link
Member

rjsparks commented Oct 9, 2025

Right - Think of rfc20.

But I may have reacted to where you were pointing in the code incorrectly - are you trying to solve the sorting on pages like https://datatracker.ietf.org/doc/rfc3261/? If so, then the code you're looking at in utils_search isn't relevant. That's used for pages like https://datatracker.ietf.org/group/sip/documents/ (which looks sorted to me already).

If it's the first kind of link you're after, you need to be looking at this view:

def document_main(request, name, rev=None, document_html=False):
, and the fix is going to be to either pull the calls in the construction of the render dict at the end forward and sort them, or maybe sort in the interesting_relations* utilities. See
return render(request, "doc/document_rfc.html" if document_html is False else "doc/document_html.html",
dict(doc=doc,
document_html=document_html,
css=css,
js=js,
html=html,
group=group,
top=top,
name=doc.name,
content=content,
split_content=split_content,
revisions=simple_diff_revisions if document_html else revisions,
latest_rev=latest_rev,
can_edit=can_edit,
can_edit_authors=can_edit_authors,
can_change_stream=can_change_stream,
rfc_number=doc.rfc_number,
updates=interesting_relations_that_doc.filter(relationship="updates"),
updated_by=interesting_relations_that.filter(relationship="updates"),
obsoletes=interesting_relations_that_doc.filter(relationship="obs"),
obsoleted_by=interesting_relations_that.filter(relationship="obs"),
status_changes=status_changes,
proposed_status_changes=proposed_status_changes,
has_errata=doc.pk and doc.tags.filter(slug="errata"), # doc.pk == None if using a fake_history_obj
file_urls=file_urls,
rfc_editor_state=doc.get_state("draft-rfceditor"),
iana_review_state=doc.get_state("draft-iana-review"),
iana_action_state=doc.get_state("draft-iana-action"),
iana_experts_state=doc.get_state("draft-iana-experts"),
iana_experts_comment=iana_experts_comment,
presentations=presentations,
diff_revisions=diff_revisions,
submission=submission,
mailto_name=mailto_name,
))

@rjsparks
Copy link
Member

Eliot - do you want to continue pushing on this to drive learning, or do you want us to pick it up?

@elear
Copy link
Contributor Author

elear commented Oct 16, 2025

Hi Robert- I won't have time to dink this until the IETF. If you want to move faster, please feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants