Org Web Adapter

hungryroot/jira/be_7135_update_the_customersearchview_test_automation_endpoint_to_support_filtering_by_primary_diet_type.org

ID
93b0d7a3-be34-406b-a547-022c7fbd4199

BE-7135 Update the CustomerSearchView test automation endpoint to support filtering by primary diet type

- source :: https://hungryroot.atlassian.net/browse/BE-7135

- tags :: Hungryroot API Project

- epic :: EP-411 Eng Parking Lot

- sprint :: HR BE Sprint 104

- status :: Status - To Do

Description

Update the CustomerSearchView test automation endpoint to support filtering

customers by their primary diet type (e.g., omnivore, vegetarian, vegan,

pescatarian).

Background

The CustomerSearchView (test_automation/views/customer_search.py) currently

supports filtering by:

Delivered orders count

Customer status (active, held, cancelled)

Preferred delivery date

Ratable order status

Test automation needs the ability to find customers by primary diet so that

diet-specific test scenarios (e.g., verifying vegan product recommendations,

validating vegetarian meal plans) can locate appropriate test customers without

manual lookup.

Requirements

Add a new primary_diet filter to CustomerSearchFilter that filters customers

based on the boolean diet fields on the related CustomerInfo model

(customer_info):

is_vegan

is_vegetarian

is_pescatarian

is_omnivore

The filter should accept a choice value (e.g., ?primary_diet=vegan) and filter

the queryset by joining through the customer_info relationship (e.g.,

customer_info__is_vegan=True).

Accepted filter values

Value

Field

vegan

customer_info__is_vegan

vegetarian

customer_info__is_vegetarian

pescatarian

customer_info__is_pescatarian

omnivore

customer_info__is_omnivore

Implementation Notes

Add a ChoiceFilter with a custom method on CustomerSearchFilter, following the

same pattern as the existing status filter.

Consider adding select_related("customer_info") to the get_queryset() method for

query efficiency since the filter joins on customer_info.

The CustomerSearchSerializer fields may optionally be expanded to include the

diet in the response, but this is not required.

Acceptance Criteria

[ ] GET /test-automation/customer-search/?primary_diet=vegan returns only

customers where customer_info.is_vegan=True

[ ] Same behavior for vegetarian, pescatarian, and omnivore

[ ] Invalid diet values are rejected or ignored gracefully

[ ] Existing filters continue to work and can be combined with the new diet

filter

[ ] Tests cover the new filter