Skip to content

NW6 | Fathi Kahin | Module-Database | E-commerce -API-| Week 4 #178

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fhkahin
Copy link

@fhkahin fhkahin commented Jun 5, 2024

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

Copy link

sonarqubecloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@taccarlo
Copy link

Hello @fhkahin! I'm new here. I tested your work with Postman, and it's impressive. I have a few suggestions:

  1. I don't understand why the .env file is not included in the .gitignore list.

  2. The .env.example file uses DB_USERNAME and DB_DATABASE, but in your code, you use DB_NAME and DB_USER instead.

  3. In R.2, you only provide the product ID when running the query:

     SELECT product_name FROM products WHERE product_name ILIKE '%Ball%';
    

    I suggest using a join, similar to R.1, and adding restrictions with an AND operation to get more detailed information:

     SELECT p.product_name, pa.unit_price, s.supplier_name FROM products p INNER JOIN product_availability pa ON (p.id = pa.prod_id AND product_name ILIKE '%Ball%') INNER JOIN suppliers s ON (s.id = pa.supp_id)
    

    This way, you can view the properties of the searched product (e.g., unit price and supplier name) instead of just the product name, which is not very informative.

  4. Why not use req.query['name'] in R.2 and req.query['customerId'] in R.3? This would allow us to use the URLs localhost:3030/products?name=Ball and localhost:3030/customers?customerId=1. If you choose this approach, remember to change line 24:

     ILIKE '%$1%'
    

    to

     ILIKE '%' || $1 || '%'
    

    and remove :name from line 21 and :customerId from line 33.

I am Carlo. Please let me know if you need any clarification on my review.

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.

2 participants