Closed ethanbaruh closed 1 month ago
Name | Link |
---|---|
Latest commit | 27ba4b085c3467158468a8b5bd611b3325b5c653 |
Latest deploy log | https://app.netlify.com/sites/foodjournal2/deploys/6648f6c9fb33b000087e2be4 |
✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.
Package | Version | Score | Details |
---|
Abstract
This PR includes changes to the backend in order to create an API endpoint for querying post reviews from the SQL database as well the logic for the endpoint. These changes are implemented in the backend/post_review/ folder in the router.py and service.py files.
router.py
handles the endpoint with the functionget_post_reviews
with the endpoint located at/api/v1/post_review/get_post_review
. The logic to actually query the SQL database is inservice.py
in the functionget_post_reviews
which queries the database and selects a preset number of posts. Right now the max number of posts to get is set at 20 although it can be changed through the constantMAX_POSTS_TO_FETCH
inservice.py
.Issues
Closes #24
Type of Change
Testing
Tests for the
service.py
file are located atbackend/tests/testPostModel.py
and include tests to query the database and ensure that the posts that are fetched are correct. In addition to test the endpoint I performed manually testing by ensuring that there was data in the database, runningpython main.py
in thebackend
directory to ensure that the backend server was running. I then went tohttp://0.0.0.0:6542/api/v1/post_review/get_post_review
in a browser and saw that the returned JSON data matched the data in the SQL database.Checklist