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

[Backend] added: function add dummy data #84

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

EllynChan
Copy link
Collaborator

@EllynChan EllynChan commented Mar 13, 2023

Overview

Added new function add-dummy-data
API: api/user/dummy

Checklist

  • Conventional commits are followed.
  • yarn format completed for BACKEND and FRONTEND.
  • yarn verify completed.
  • The new work has been locally tested and before and after screenshots are provided.
  • There are no package lock files (only yarn should be used) - frontend only.
  • The autogenerated samconfig.tomlis left out - backend only.

References

@EllynChan EllynChan changed the title added: function add dummy data [Backend] added: function add dummy data Mar 13, 2023
let insertUsers = await new Promise((resolve, reject) => {
con.query(queryString, function (err, res) {
if (err) {
reject("Error insert into users");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the error message, not a generic message.
if (err) { reject(err);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although returning the error might give you a better idea of what failed, you still need to return where the error failed as well. Perhaps turning the existing reject to a console.log and adding the reject(err) would be best.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes please review again

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! @alkhatibmahmoud

let insertListing = await new Promise((resolve, reject) => {
con.query(queryString, function (err, res) {
if (err) {
reject("Error insert into listings");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, please do that for all of them. Thanks!

@JoshLuong
Copy link
Collaborator

JoshLuong commented Mar 14, 2023

I think we may have to wait and modify the script once we have image upload Table

});
});

const addListingsQueries = [`INSERT INTO Listing (ListingID, UserID, ListingName, Description, Cost, Quantity, Category, ItemCondition, PostedTimestamp, IsActiveListing) VALUES (1, 1, "listing1", "listing1 description", 10.50, 5, "category1", "used", "2023-03-01 12:00:00", true)`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure that this data actually matches what is expected, and have proper listing names, descriptions, prices, etc. Categories can be https://github.com/CPSC319-2022/AmazonianPrime/blob/main/frontend/src/components/common/Categories.ts, condition will be https://github.com/CPSC319-2022/AmazonianPrime/pull/74/files#diff-562650c992ad334fbfdb3162f4407dc3b4a0036d21a884e2b634dc591b313264R33

backend/functions/add-dummy-data/app.js Outdated Show resolved Hide resolved
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.

4 participants