UVicMartletplace / martletplace

Recreating FB Marketplace for Students - UVic SENG499 Capstone Project
0 stars 0 forks source link

Implement Return Search Results API #50

Closed GDeane closed 3 months ago

GDeane commented 4 months ago

Feature Description

Implement the search API to return listings based on various criteria like keywords, category, price range, etc.

All of these Request Payload Parameters need to be implemented, supported, and tested:

It shall accept a valid sample request payload as stated in SRS Section 5.1.4.1, and return a corresponding success response with an array of (limit) listings.

It shall return a 400 Invalid Request error in the case that any parameters are missing or incorrectly formatted.

It shall additionally update the Postgres database with the search query for the user's search history purposes.

relates: nothing yet blocked by: nothing yet

Problem You're Trying to Solve

User Stories To Implement

  1. "As a user, I want to search for listings based on certain keywords and criteria, so that I can find items to buy."
  2. "As a user, I want to search for sellers, so that I can find specific users and view their listings."
  3. "As a registered user, I want to be able to view my search history, so that I can revisit previous searches or items."

Related External Resources

SRS Section 5.1.4.1

189

Acceptance Criteria

Sorted by User story

User Story 1: "As a user, I want to search for listings based on certain keywords and criteria, so that I can find items to buy."

Unit Tests:

  1. Filter Application:

    • Test that the search query filters by keywords correctly.
    • Test that the price range filter (minPrice and maxPrice) is applied correctly.
    • Test that the status filter (AVAILABLE, SOLD) is applied correctly.
    • Test that the location filter (latitude, longitude) is applied correctly within a 5 km radius.
  2. Sorting Functionality:

    • Test that the sorting by relevance is applied correctly.
    • Test that the sorting by price (ascending and descending) is applied correctly.
    • Test that the sorting by listed time (ascending and descending) is applied correctly.
    • Test that the sorting by distance (ascending and descending) is applied correctly.
  3. Pagination:

    • Test that the pagination works correctly by retrieving the correct number of results per page.
    • Test that the correct page number is returned for multiple pages.

Acceptance Tests:

  1. Search Results:

    • Given a valid search query, when the user searches for listings, then the system should return listings that match the search criteria.
    • Given a search query with a specified price range, when the user searches, then the system should return listings within the specified price range.
    • Given a search query with a status filter, when the user searches, then the system should return listings with the specified status.
    • Given a search query with a location filter, when the user searches, then the system should return listings within 5 km of the specified location.
  2. Sorting:

    • Given a search query, when the user sorts by relevance, then the system should return listings sorted by relevance.
    • Given a search query, when the user sorts by price (ascending/descending), then the system should return listings sorted by price.
    • Given a search query, when the user sorts by listed time (ascending/descending), then the system should return listings sorted by listed time.
    • Given a search query, when the user sorts by distance (ascending/descending), then the system should return listings sorted by distance.
  3. Pagination:

    • Given a search query, when the user requests a specific page, then the system should return the correct listings for that page.
    • Given a search query, when the user specifies a limit of results per page, then the system should return the specified number of listings per page.

User Story 2: "As a user, I want to search for sellers, so that I can find specific users and view their listings."

Unit Tests:

  1. User Search:

    • Test that the search query filters by seller name correctly when searchType is input as USERS.
  2. Listings Retrieval:

    • Test that the listings associated with a seller are retrieved correctly.

Acceptance Tests:

  1. Seller Listings:
    • Given a valid search query, when the user searches for a specific seller, then the system should display the listings associated with that seller.

User Story 3: "As a registered user, I want to be able to view my search history, so that I can revisit previous searches or items."

Unit Tests:

  1. Search History Storage:
    • Test that a search query is stored in the PostgreSQL database correctly (most recent first).
    • Test that the search history is associated with the correct user.

Acceptance Tests:

  1. Search History Storage:

    • Given a registered user, when the user performs a search, then the system should store the search query in the PostgreSQL database associated with the user.
    • Given a registered user, when the user performs multiple searches, then the system should store each search query in the PostgreSQL database associated with the user.
  2. Search History Retrieval:

    • Given a registered user, when the user views their search history, then the system should retrieve and display the search history from the PostgreSQL database.
    • Given a registered user, when the user views their search history, then the system should display the search queries in the correct order (most recent first).
GDeane commented 3 months ago

The search history functionality has been moved into a separate ticket (#189), as the PR was getting too big