feat: POST for document search requests#8206
Merged
rjsparks merged 15 commits intoietf-tools:mainfrom Nov 14, 2024
Merged
Conversation
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
rjsparks
reviewed
Nov 13, 2024
| @@ -124,14 +124,11 @@ def chart_newrevisiondocevent(request): | |||
|
|
|||
| #@cache_page(60*15) | |||
| def chart_data_newrevisiondocevent(request): | |||
Member
There was a problem hiding this comment.
Pretty sure this doesn't work as intended, and it's not being used, so lets remove it.
rjsparks
previously approved these changes
Nov 14, 2024
Member
Author
|
Marking as draft until #8210 is merged. I'll pull that into this branch and do cleanup here. |
# Conflicts: # ietf/doc/views_stats.py
rjsparks
approved these changes
Nov 14, 2024
Codecov ReportAttention: Patch coverage is
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SearchFormsince it depends on details internal to the form. This helps with a circular import problem.The
SearchFormand 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:
messages.error()notice to reflect that the GET interface is retired, not just deprecated/doc/<some-value>are all covered by this patchsearch_for_nameview is probably in need of a refactor, but it's really a separate task so I'm not going to change it here./doc/whateveras an alias for searching.It'd also be nice to update the
search_form.htmltemplate 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.