Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 17, 2024
1 parent a47fb9e commit 204075f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions cl/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SearchQuery(models.Model):
def str(self):
return f"Query: {self.get_params} at {self.date_created}"


class PRECEDENTIAL_STATUS:
PUBLISHED = "Published"
UNPUBLISHED = "Unpublished"
Expand Down
33 changes: 25 additions & 8 deletions cl/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@
UnbalancedQuotesQuery,
)
from cl.search.forms import SearchForm, _clean_form
from cl.search.models import SEARCH_TYPES, Court, Opinion, OpinionCluster, SearchQuery
from cl.search.models import (
SEARCH_TYPES,
Court,
Opinion,
OpinionCluster,
SearchQuery,
)
from cl.stats.models import Stat
from cl.stats.utils import tally_stat
from cl.visualizations.models import SCOTUSMap

logger = logging.getLogger(__name__)


def check_pagination_depth(page_number):
"""Check if the pagination is too deep (indicating a crawler)"""

Expand Down Expand Up @@ -511,7 +518,7 @@ def show_results(request: HttpRequest) -> HttpResponse:
# Just a regular search
if not is_bot(request):
async_to_sync(tally_stat)("search.results")

# Perform the search
search_type = request.GET.get("type", SEARCH_TYPES.OPINION)

Expand All @@ -520,23 +527,32 @@ def show_results(request: HttpRequest) -> HttpResponse:
elif search_type == SEARCH_TYPES.ORAL_ARGUMENT:
# Check if waffle flag is active.
if waffle.flag_is_active(request, "oa-es-active"):
render_dict.update(do_es_search(request.GET.copy()))
render_dict.update(
do_es_search(request.GET.copy())
)
else:
render_dict.update(do_search(request.GET.copy()))
elif search_type == SEARCH_TYPES.PEOPLE:
if waffle.flag_is_active(request, "p-es-active"):
render_dict.update(do_es_search(request.GET.copy()))
render_dict.update(
do_es_search(request.GET.copy())
)
else:
render_dict.update(do_search(request.GET.copy()))
elif search_type in [SEARCH_TYPES.RECAP, SEARCH_TYPES.DOCKETS]:
elif search_type in [
SEARCH_TYPES.RECAP,
SEARCH_TYPES.DOCKETS,
]:
if waffle.flag_is_active(request, "r-es-active"):
search_results = do_es_search(request.GET.copy())
else:
search_results = do_search(request.GET.copy())
render_dict.update(search_results)
elif search_type == SEARCH_TYPES.OPINION:
if waffle.flag_is_active(request, "o-es-active"):
render_dict.update(do_es_search(request.GET.copy()))
render_dict.update(
do_es_search(request.GET.copy())
)
else:
render_dict.update(do_search(request.GET.copy()))
elif search_type == SEARCH_TYPES.RECAP_DOCUMENT:
Expand All @@ -547,8 +563,8 @@ def show_results(request: HttpRequest) -> HttpResponse:
# Create and save the SearchQuery object
SearchQuery.objects.create(
get_params=request.GET.urlencode(),
query_time_ms=render_dict.get('query_time', 0),
hit_cache=render_dict.get('hit_cache', False)
query_time_ms=render_dict.get("query_time", 0),
hit_cache=render_dict.get("hit_cache", False),
)

# Create bare-bones alert form.
Expand All @@ -565,6 +581,7 @@ def show_results(request: HttpRequest) -> HttpResponse:

return TemplateResponse(request, "search.html", render_dict)


def advanced(request: HttpRequest) -> HttpResponse:
render_dict = {"private": False}

Expand Down

0 comments on commit 204075f

Please sign in to comment.