Skip to content

Commit

Permalink
Fix admin search slow
Browse files Browse the repository at this point in the history
- Implement new AdvancedAdminSearchMixin
- Don't convert every value to text for search, so DB indexes can be used
- Change admin search from `iexact (=)`  to `exact (==)`
  • Loading branch information
Uxio0 committed Nov 13, 2023
1 parent 95c3fe3 commit 363715c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions safe_transaction_service/utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def queryset(self, request, queryset):
return queryset


# TODO Use the class in safe-eth-py
class AdvancedAdminSearchMixin:
"""
Use database indexes when using exact search instead
Expand All @@ -40,9 +41,6 @@ def get_search_results(self, request, queryset, search_term):
to allow `exact` search that uses database indexes
"""

# Apply keyword searches.
print("HOLA")

def construct_search(field_name):
if field_name.startswith("^"):
return "%s__istartswith" % field_name[1:]
Expand Down

0 comments on commit 363715c

Please sign in to comment.