UVicMartletplace / martletplace

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

Gavin/189 make return search results api update search history #193

Closed GDeane closed 3 days ago

GDeane commented 1 week ago

Description

This PR gets the search API endpoint to update the user_searches table whenever a search is made. It also refactors the search engine code to be more readable.

This should be merged after emila's reindexing PR If you have not reviewed that PR, do so first.

This PR does not include authorization. It uses user_id = 5 as a placeholder (@MNThomson said he'd manage that when setting up jwt token stuff)

Closes #189

How to Test

  1. Checkout this branch

  2. In a terminal, navigate to the martletplace directory and run docker-compose up --build

  3. Wait a minute for the data layer (particularly elasticsearch) to get ready for input

  4. In a terminal, run docker exec -it martletplace_search bash

  5. In the bash terminal, run pytest src/test_server.py

How to test manually

  1. Uncomment the search engine port for testing purposes (DO NOT COMMIT THIS CHANGE) image

  2. Run a fresh docker-compose up --build

  3. Once everything is up and running, run docker-exec -it martletplace_database base

  4. In the bash terminal, run psql -p 8310 -U martletplace -h localhost

  5. run select * from user_searches; image

  6. In your browser, navigate to http://localhost:8221/docs image

  7. Open the search endpoint, click "try it out", fill in some (valid) dummy values, and click 'execute' image

  8. In the database bash terminal, run select * from user_searches;

  9. The table should have an additional entry for user_id = 5

Checklist

GDeane commented 1 week ago

Currently the testing is finicky, trying to figure it out

GDeane commented 6 days ago

Now it's mostly working. I just need to write tests for this functionality