Skip to content
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

🤖 Refactor Inventory Management and Add Atomic Update Functionality #639

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sentry-autofix[bot]
Copy link
Contributor

👋 Hi there! This PR was automatically generated by Autofix 🤖

This fix was triggered by Rohan Agarwal

Fixes FLASK-YM

The code changes refactor the inventory management functions in db.py and main.py. In db.py, the get_inventory function has been simplified to use a list comprehension for collecting product IDs and now formats the SQL query using parameters to prevent SQL injection. An update_inventory_quantity function is introduced to atomically update the inventory count after successful checkout, ensuring inventory remains consistent during transactions. In main.py, logic for validating inventory has been improved with clearer exception handling and a map is created for efficient checks. The new inventory update process is integrated, ensuring that the inventory is updated atomically for each product in the cart.

If you have any questions or feedback for the Sentry team about this fix, please email [email protected] with the Run ID: 2126.

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
empower ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 4:50pm

Copy link

sentry-io bot commented Dec 10, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: flask/src/db.py

Function Unhandled Issue
get_inventory DatabaseConnectionError: get_inventory checkout
Event Count: 4
📄 File: flask/src/main.py (Click to Expand)
Function Unhandled Issue
checkout Exception: Not enough inventory for product checkout
Event Count: 3.6k
checkout DatabaseConnectionError: get_inventory checkout
Event Count: 4
---

Did you find this useful? React with a 👍 or 👎

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 40 lines in your changes missing coverage. Please review.

Project coverage is 35.16%. Comparing base (75af4e6) to head (a44fb26).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
flask/src/main.py 0.00% 26 Missing ⚠️
flask/src/db.py 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #639      +/-   ##
==========================================
- Coverage   36.21%   35.16%   -1.06%     
==========================================
  Files          37       37              
  Lines         867      893      +26     
  Branches      111      111              
==========================================
  Hits          314      314              
- Misses        536      562      +26     
  Partials       17       17              
Flag Coverage Δ
api 7.08% <0.00%> (-0.55%) ⬇️
frontend 54.75% <ø> (ø)
Components Coverage Δ
checkout_module 7.08% <0.00%> (-0.55%) ⬇️
product_component 56.41% <ø> (ø)
Files with missing lines Coverage Δ
flask/src/db.py 0.00% <0.00%> (ø)
flask/src/main.py 0.00% <0.00%> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants