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

feat: POST for document search requests #8206

Merged
merged 15 commits into from
Nov 14, 2024

Conversation

jennifer-richards
Copy link
Member

@jennifer-richards jennifer-richards commented Nov 13, 2024

This refactors the ietf.doc.search() view and some adjacent views to require a POST, including a CSRF key, before executing a document search. Search parameters are expected in the request body instead of the URL query string.

If a GET request with a query string is received the search is not executed. The user is sent back to the search page with the form pre-filled using the values from their request and an error box at the top of the page indicates that the GET interface is deprecated. (Maybe there's a better term - it's actually been retired - so suggestions on phrasing are welcome.)

I've refactored the cache key calculation and moved it into the SearchForm since it depends on details internal to the form. This helps with a circular import problem.

The SearchForm and results cache is reused in the stats module. I've so far refactored this to use the updated form but not to switch it over to POST. I haven't seen anything actually hit that endpoint in over 30 days (though I haven't exhaustively searched logs), so maybe it's better to drop it. That'd allow removal of an additional helper function that really doesn't need to exist.

A few things left before taking this out of draft:

  • check / update tests
  • rephrase the messages.error() notice to reflect that the GET interface is retired, not just deprecated
  • confirm that the expensive forms of /doc/<some-value> are all covered by this patch
    • The search_for_name view is probably in need of a refactor, but it's really a separate task so I'm not going to change it here.
    • When no simple match is found, a redirect to the GET-based search is returned. I think that's ok - we want to wean people away from using /doc/whatever as an alias for searching.

It'd also be nice to update the search_form.html template to display form validation errors. I'm on the fence as to whether that's a separate feature or belongs here. Thinking it is probably separate and that the better fix should also handle opening the "Additional search criteria" accordion when non-default options are selected.

Changes the search view to use a POST instead of a GET. Refactors cache key computation to use cleaned data.

Still todo:
 * refactor frontpage view to match
 * refactor menubar search (?)
 * refactor stats view that uses SearchForm
 * revive or drop the "backwards compatibility" branch
Still todo:
 * refactor frontpage view to match
 * refactor menubar search (?)
 * refactor stats view that uses SearchForm
Still todo:
 * refactor stats view that uses SearchForm
@jennifer-richards jennifer-richards marked this pull request as ready for review November 13, 2024 21:23
@@ -124,14 +124,11 @@ def chart_newrevisiondocevent(request):

#@cache_page(60*15)
def chart_data_newrevisiondocevent(request):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this doesn't work as intended, and it's not being used, so lets remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removal done in #8210

rjsparks
rjsparks previously approved these changes Nov 14, 2024
@jennifer-richards jennifer-richards marked this pull request as draft November 14, 2024 16:02
@jennifer-richards
Copy link
Member Author

Marking as draft until #8210 is merged. I'll pull that into this branch and do cleanup here.

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 90.69767% with 4 lines in your changes missing coverage. Please review.

Project coverage is 88.94%. Comparing base (c7f6bde) to head (5e2bf29).
Report is 181 commits behind head on main.

Files with missing lines Patch % Lines
ietf/doc/views_search.py 90.24% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8206      +/-   ##
==========================================
+ Coverage   88.78%   88.94%   +0.15%     
==========================================
  Files         296      303       +7     
  Lines       41320    41260      -60     
==========================================
+ Hits        36687    36699      +12     
+ Misses       4633     4561      -72     

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

@rjsparks rjsparks merged commit b65a37b into ietf-tools:main Nov 14, 2024
9 checks passed
@jennifer-richards jennifer-richards deleted the no-search-by-get branch November 15, 2024 13:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants