CSE-112-Team-3 / FoodJournal2.0

our new repository
1 stars 2 forks source link

added get posts query and endpoint #27

Closed ethanbaruh closed 1 month ago

ethanbaruh commented 1 month ago

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 function get_post_reviews with the endpoint located at /api/v1/post_review/get_post_review. The logic to actually query the SQL database is in service.py in the function get_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 constant MAX_POSTS_TO_FETCH in service.py.

Issues

Closes #24

Type of Change

Testing

Tests for the service.py file are located at backend/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, running python main.py in the backend directory to ensure that the backend server was running. I then went to http://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

netlify[bot] commented 1 month ago

Deploy Preview for foodjournal2 canceled.

Name Link
Latest commit 27ba4b085c3467158468a8b5bd611b3325b5c653
Latest deploy log https://app.netlify.com/sites/foodjournal2/deploys/6648f6c9fb33b000087e2be4
github-actions[bot] commented 1 month ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files