akshitagupta15june / PetMe-Prod

PetMe-Prod is an all-in-one platform that allows animals to be adopted, donated to pet lovers, and provides emergency medical care to stray animals in need.
https://pet-me-prod-pet-me-frontend.vercel.app/
MIT License
13 stars 37 forks source link

Feature/advanced search Backend API complete and tested. #60

Closed gayatri-p786 closed 2 weeks ago

gayatri-p786 commented 3 weeks ago

This PR introduces an advanced search filtering feature for the pet adoption system, allowing users to search for pets based on various criteria including type, breed, age, size, gender, location, and adoption fee.

**Key Features: 1. Advanced Search Filtering:** Type of Animal: Filter by categories like Cat, Dog, Bird, Rabbit, Reptile, and Other. Breed: Filter by specific or mixed breeds. Age: Categories include Puppy/Kitten, Young, Adult, Senior. Size: Small, Medium, Large. Gender: Male, Female. Location: Filter by distance or specific city/region. Adoption Fee: Free, Under $50, $50-$100, Over $100.

2. Backend Enhancements: Controller: AdoptionSearchController.ts handles search requests and returns filtered results with error handling. Service: AdoptionService.ts implements the filtering logic and interfaces with the PetModel. Model: PetModel.ts fetches and filters pet records from the database. Database Schema: Updated Pets model with new fields (gender, age, size, location, adoption_fee) and applied migrations.

3. Comprehensive Testing: Added unit and integration tests for AdoptionSearchController to ensure correct handling of search requests and errors.

cb7chaitanya commented 2 weeks ago

@gayatri-p786 Fantastic PR, excellent work on the integration and unit tests specifically, can you do one thing for me? Just add the request-response body in the comments, so that i can add them to the notion doc and merge the PR

gayatri-p786 commented 2 weeks ago

Example Request URL:

Example Succesful Response Body: { "message": "Search results", "pets": [ { "id": "12345", "name": "Buddy", "color_id": "1", "pet_img": "buddy.jpg", "breed_id": "2", "type_id": "Dog", "gender": "Male", "age": "Adult", "size": "Large", "location": "New York", "adoption_fee": "100", "pet_breed": { "id": "2", "name": "Golden Retriever" }, "pet_color": { "id": "1", "name": "Golden" }, "pet_type": { "id": "Dog", "name": "Dog" } } // Other pets matching the criteria ] }

Example Error Response: { "message": "Error while searching pets", "error": "Something went wrong" }

Note: Please confirm with Vineet if he is working on the frontend in this branch and then merge the PR. Thanks!