Skip to content

Commit

Permalink
Merge branch 'main' into 3308-document-link
Browse files Browse the repository at this point in the history
  • Loading branch information
mlissner authored Nov 21, 2024
2 parents 413f707 + 20435ec commit 99b4698
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
26 changes: 12 additions & 14 deletions cl/search/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
logger = logging.getLogger(__name__)


def get_object_list(request, cd, paginator):
def get_object_list(request, cd, paginator, es_flag_status):
"""Perform the Solr work"""
# Set the offset value
try:
Expand All @@ -56,21 +56,19 @@ def get_object_list(request, cd, paginator):
if cd["type"] == SEARCH_TYPES.DOCKETS:
group = True

is_oral_argument_active = cd[
"type"
] == SEARCH_TYPES.ORAL_ARGUMENT and waffle.flag_is_active(
request, "oa-es-activate"
is_oral_argument_active = (
cd["type"] == SEARCH_TYPES.ORAL_ARGUMENT and es_flag_status
)
is_people_active = cd[
"type"
] == SEARCH_TYPES.PEOPLE and waffle.flag_is_active(request, "p-es-active")
is_opinion_active = cd["type"] == SEARCH_TYPES.OPINION and (
waffle.flag_is_active(request, "o-es-search-api-active")
is_people_active = cd["type"] == SEARCH_TYPES.PEOPLE and es_flag_status
is_opinion_active = cd["type"] == SEARCH_TYPES.OPINION and es_flag_status
is_recap_active = (
cd["type"]
in [
SEARCH_TYPES.RECAP,
SEARCH_TYPES.DOCKETS,
]
and es_flag_status
)
is_recap_active = cd["type"] in [
SEARCH_TYPES.RECAP,
SEARCH_TYPES.DOCKETS,
] and (waffle.flag_is_active(request, "r-es-search-api-active"))

if is_oral_argument_active:
search_query = AudioDocument.search()
Expand Down
45 changes: 31 additions & 14 deletions cl/search/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,36 +269,53 @@ class SearchViewSet(LoggingMixin, viewsets.ViewSet):

def list(self, request, *args, **kwargs):

is_opinion_active = waffle.flag_is_active(
request, "o-es-search-api-active"
)
search_form = SearchForm(request.GET, is_es_form=is_opinion_active)
match request.GET.get("type", SEARCH_TYPES.OPINION):
case SEARCH_TYPES.ORAL_ARGUMENT if waffle.flag_is_active(
request, "oa-es-active"
):
es_flag_is_active = True
case SEARCH_TYPES.PEOPLE if waffle.flag_is_active(
request, "p-es-active"
):
es_flag_is_active = True
case SEARCH_TYPES.OPINION if waffle.flag_is_active(
request, "o-es-search-api-active"
):
es_flag_is_active = True
case (
SEARCH_TYPES.RECAP | SEARCH_TYPES.DOCKETS
) if waffle.flag_is_active(request, "r-es-search-api-active"):
es_flag_is_active = True
case _:
es_flag_is_active = False

search_form = SearchForm(request.GET, is_es_form=es_flag_is_active)
if search_form.is_valid():
cd = search_form.cleaned_data

search_type = cd["type"]
paginator = pagination.PageNumberPagination()
sl = api_utils.get_object_list(request, cd=cd, paginator=paginator)
sl = api_utils.get_object_list(
request,
cd=cd,
paginator=paginator,
es_flag_status=es_flag_is_active,
)
result_page = paginator.paginate_queryset(sl, request)

match search_type:
case SEARCH_TYPES.ORAL_ARGUMENT if waffle.flag_is_active(
request, "oa-es-active"
):
case SEARCH_TYPES.ORAL_ARGUMENT if es_flag_is_active:
serializer = V3OAESResultSerializer(result_page, many=True)
case SEARCH_TYPES.PEOPLE if waffle.flag_is_active(
request, "p-es-active"
):
case SEARCH_TYPES.PEOPLE if es_flag_is_active:
serializer = ExtendedPersonESSerializer(
result_page, many=True
)
case SEARCH_TYPES.OPINION if is_opinion_active:
case SEARCH_TYPES.OPINION if es_flag_is_active:
serializer = V3OpinionESResultSerializer(
result_page, many=True
)
case (
SEARCH_TYPES.RECAP | SEARCH_TYPES.DOCKETS
) if waffle.flag_is_active(request, "r-es-search-api-active"):
) if es_flag_is_active:
serializer = V3RECAPDocumentESResultSerializer(
result_page, many=True
)
Expand Down

0 comments on commit 99b4698

Please sign in to comment.