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
Checkout this branch
In a terminal, navigate to the martletplace directory and run docker-compose up --build
Wait a minute for the data layer (particularly elasticsearch) to get ready for input
In a terminal, run docker exec -it martletplace_search bash
In the bash terminal, run pytest src/test_server.py
How to test manually
Uncomment the search engine port for testing purposes (DO NOT COMMIT THIS CHANGE)
Run a fresh docker-compose up --build
Once everything is up and running, run docker-exec -it martletplace_database base
In the bash terminal, run psql -p 8310 -U martletplace -h localhost
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
Checkout this branch
In a terminal, navigate to the martletplace directory and run
docker-compose up --build
Wait a minute for the data layer (particularly elasticsearch) to get ready for input
In a terminal, run
docker exec -it martletplace_search bash
In the bash terminal, run
pytest src/test_server.py
How to test manually
Uncomment the search engine port for testing purposes (DO NOT COMMIT THIS CHANGE)![image](https://github.com/UVicMartletplace/martletplace/assets/90437591/affc2adc-73ec-424b-a82b-18a906714820)
Run a fresh
docker-compose up --build
Once everything is up and running, run
docker-exec -it martletplace_database base
In the bash terminal, run
psql -p 8310 -U martletplace -h localhost
run![image](https://github.com/UVicMartletplace/martletplace/assets/90437591/8038f94b-d3cf-4e8c-abe4-96614126f1e5)
select * from user_searches;
In your browser, navigate to http://localhost:8221/docs![image](https://github.com/UVicMartletplace/martletplace/assets/90437591/fd53cb17-877e-4f62-92dc-1696b08bfbe8)
Open the search endpoint, click "try it out", fill in some (valid) dummy values, and click 'execute'![image](https://github.com/UVicMartletplace/martletplace/assets/90437591/9efa6283-de37-414a-89e3-9aa3ea1be5e4)
In the database bash terminal, run
select * from user_searches;
The table should have an additional entry for user_id = 5
Checklist