-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Implement new API routes to fetch blog posts by authorIds
and to update a post
#2
Open
huaszu
wants to merge
79
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
9c54e06
Start route that handles GET request for posts having at least one of…
huaszu 604f094
Update api/posts.py
huaszu 6904073
Update URL of route and update return statement to have proper jsonif…
huaszu 6589caf
Update URL of route and update return statement to have proper jsonif…
huaszu 3774363
Correct URL to match specification. Shorten docstring.
huaszu 68326a5
Make list of author_ids where each author_id is an integer
huaszu 470cbf2
Make list of Post objects to represent in response
huaszu 44f5f61
Make dictionary containing information to include in response. Forma…
huaszu d660db7
Handle case of user entering duplicate authors.
huaszu 3a6f17b
Comment to explain use of dictionary.
huaszu 9612dc6
Add file to ignore
huaszu 76e5d03
Add key-value pair to inner dictionary of posts_data dictionary to he…
huaszu 2e26c4b
Implement two directions for sorting blog posts.
huaszu cb60657
Suggest potential refactoring.
huaszu 04b70b7
Handle error when required query parameter is missing. Handle error …
huaszu c5b84d0
Change error checking of direction by which to sort posts to help wit…
huaszu 648c0f8
Initial commit
huaszu 3a1e6b6
Implement type hints.
huaszu c208ca4
Update comment on alternative solution.
huaszu 5529ef6
Refactor so as not to make unnecessary list of Post objects.
huaszu 9a4d4c4
Use sets to consider unique author ids and unique posts. Handle case…
huaszu dbf2ea6
Update variable names for clarity. Make code more concise by removin…
huaszu 24f1be2
Move file for better organization.
huaszu 732a030
Use set comprehension. Save line of code that initialized an empty set.
huaszu b01a21f
Incorporate set comprehension. Initialize a set intended to be a sup…
huaszu 6773aa4
Use list comprehension.
huaszu 3ac2e08
Update error to warning.
huaszu dd9e9a9
Ensure that only a logged in can use this route.
huaszu c3f5764
Start route to update a blog post. Validate that user is logged in. …
huaszu 7f3a782
Add instance method to get a post by post id.
huaszu c88810a
Enable logged in user to modify authorIds, tags, or text of post. Wh…
huaszu 1da081a
Test use of row_to_dict(row) function.
huaszu 8674425
Prepare format for Response Body.
huaszu 1855fc0
Update response.
huaszu 58917da
Attempt to get response to match exact format of specification, speci…
huaszu c4aeed8
Attempt differently to create specified order within response.
huaszu 7107958
Set sorting of keys of JSON objects alphabetically to FALSE to achiev…
huaszu f630b16
Ensure only an author of a post can update the post.
huaszu 9fcc11f
Give useful error message to user.
huaszu 0f103f9
Give warning when database has no post with requested postId. Give e…
huaszu 99c75f5
Handle error when user does not provide authorIds in the format of an…
huaszu a9fa08b
Handle error when user enters tags not in the format of an array. Ha…
huaszu 03c8bd5
Handle error when user provides text that is not a string.
huaszu 3c0a5f0
Sort tags alphabetically in response based on looking at example in s…
huaszu 24fa5d1
Undo sort of tags in response because that sort made test_posts.py::t…
huaszu 1321643
Remove unnecessary code because, for the Post class, the use of the @…
huaszu 7b9cb9c
Test using db.utils.rows_to_list(rows) helper function to get toward …
huaszu d90805e
Improve error handling to handle additional error. Refactor implemen…
huaszu 67ca0ef
Give up opportunity to deduplicate tags because, otherwise, the imple…
huaszu f4e0b34
Add static method for Post class that builds a query joining the post…
huaszu 52bc8b4
Rename file
huaszu dd7ca19
Move constant to different file. Write helper functions.
huaszu 68bb986
Write helper function to format results of database query per specifi…
huaszu 3c3abdc
Eliminate unnecessary code to handle case when there are no posts to …
huaszu e13bc1c
Fix typograhical error
huaszu 1d7f5ca
Remove unnecessary comment.
huaszu d160ce1
Rename file for clarity. Update comment for clarity.
huaszu f47e531
Use helper function to validate post_id and, if valid, return post.
huaszu e15c332
Make route more concise by factoring portions of code into helper fun…
huaszu dd272e8
Write helper function to get post and format information about post f…
huaszu 06088b0
Refactor for extensibility. Map which kind of error handling message…
huaszu 1d058c0
Rewrite for consistency and understanding.
huaszu 5437c1e
Check whether user included data in request and give helpful error me…
huaszu c712f5a
Remove unnecessary commented out code.
huaszu c52b43c
Make repository layer for functions that make queries to the database…
huaszu d0a273e
Move function that queries database to repository layer. api/util/he…
huaszu 1f55a4f
Pull out another three functions to repository layer that interact wi…
huaszu 65ce818
Remove unnecessary imports. Fix code to refer to updated file name
huaszu 7a69b51
Fix database operation to delete a UserPost record
huaszu 5dc1b3d
Using Controller-Service-Repository pattern, refactor to make reposit…
huaszu 39f41c7
Revise code to use consistent style across API routes
huaszu 56a7666
Initial commit
huaszu c628c18
Views of SQLite database for reference, with the help of https://inlo…
huaszu 088d1cd
Include prompt for easy reference. Introduce formatting for readabil…
huaszu 1e15e1a
Improve technical correctness, style, organization, and readability
huaszu 327719b
Update formatting so that all footnotes show
huaszu 26dfb89
Edit list indentation for readability
huaszu 9067923
Edit for clarity
huaszu cb0a60c
Fix spelling
huaszu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the function they gave you does validation this way
'''
validation
'''
Maybe you can do the same in your function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so far your suggestion appears to work. committed here.
i added the code you suggested. then i made this request and got this 401:
next i logged in:
now this request returned what i expected and 200 instead of the 401: