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
Restructured the backend files. Wrote toggle-favorite #105
Conversation
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.
Very important work here! Thanks David! I love this new structure! Just a minor thing to keep things consistent with your changes
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 good! Thanks again for your work on this!
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.
I think it all looks good. I like the changes. Im just worried about the other PRs if it will affect them too much if this one gets merged first
…ature/toggle_favorite # Conflicts: # app_backend/app/routers/friends.py # app_backend/tests/favorites_test.py # app_backend/tests/server_test.py
Now rebased to current dev. |
holy guacamole, David, 93 files |
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.
I don't think this PR is a good idea -- 93 files changed sounds like an error. Can you please split this PR up into the following:
- backend restructure
- toggle favorites backend
- toggle favorites frontend
I know that is tedious, but it's going to be impossible to properly review the 93 files.
When you make these PR's think about how you want to chain them -- which PR depends on which and which should be merged first. Please note that in the PR comments
I am hesitant to approve to merge this given how many files changed in just 1 PR
It is probably because I merged the development branch into my branch. I was hoping rebase will reduce the commit amount, but apparently that didn't do it. |
Try reverting the rebase and do |
…/toggle_favorite � Conflicts: � app_backend/app/routers/friends.py � app_backend/tests/server_test.py
OK I guess now it's better :) |
If you are ever worried that the merging or anything isn't good, you could always just start fresh in a new branch from dev and edit in everything you were doing. I know its a bit more work but at least you can be sure that its correct |
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.
Top priority, let's merge this asap
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.
Missed the failing tests - lets fix the tests first and then merge this asap lol
…/toggle_favorite
I'm not sure why, but it looks like the register test creates users in the production database (when it shouldn't). |
I think I found the cause |
If you're not seeing the |
I am removing TestDatabase class and using an environment variable to identify whether the server is running in test mode. |
|
||
|
||
load_dotenv() | ||
db = Database(os.getenv("DB_USERNAME"), os.getenv("DB_PASSWORD"), test_mode="pytest" in sys.modules) |
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.
Clever! Looks good to me!
I restructured backend files according to the official documentation here. I think we need to use multiple files in our backend, and it's better to start early. The doc is a bit long. Feel free to ask me if there's any part that is not clear.
I also moved the tests to the tests folder and divided tests based on their modules.
Notice that the URLs for friends APIs are now prefixed with
/friends/
. For example,/new-friends/
becomes/friends/new-friends/
.Similarly, the new one has the URL
/favorites/toggle-favorite/
.Also, notice that the new API I wrote uses JSON as a means to pass parameters (instead of the query string). Documentations on how to use it can be found here. This is the preferred way as it automatically checks for any incompatible/missing parameters, so that we don't need to write these checks by hand.