2022-Spring-NYU-DevOps-Shopcarts / shopcarts

Shopcarts squad.
Apache License 2.0
2 stars 2 forks source link

1st working version of UI-Query #137

Closed Adora2401 closed 2 years ago

codecov-commenter commented 2 years ago

Codecov Report

Merging #137 (e2f328a) into main (6a0cec8) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #137   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files           7        7           
  Lines         453      454    +1     
=======================================
+ Hits          449      450    +1     
  Misses          4        4           
Impacted Files Coverage Δ
service/routes.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6a0cec8...e2f328a. Read the comment docs.

Adora2401 commented 2 years ago

Hi all, I have no idea what these codes mean: # query string arguments shopcart_args = reqparse.RequestParser() shopcart_args.add_argument('item-id', type=int, required=False, help='List shopcarts containing the item id')

` @api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK

`

It looks like if we pass Item-id to this function, then use Shopcart.query_by_item_id(args['item-id']) instead of the following lines. However, how to pass the item-id from front-end to back-end confuses me, I have tried to use the same way as other get in our code, unfortunately, as the difference of paras, this method not works. I will really appreciate it If anyone else could take this part or give me some ideas.

TimothyXu commented 2 years ago

I cannot help if there are any UI/JavaScript issues but querying is called like this: GET on .../shopcarts?item-id=100 So you need to call that route in the js file. I don't know JavaScript so if you have problems with that I'll refer to someone else

yjjw commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

yjjw commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Adora2401 commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

yjjw commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

kdokm commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

If it is not solved tonight, I am free to offer helps also.

yjjw commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

If it is not solved tonight, I am free to offer helps also.

Hi Yuwen, I am also get stuck at this issue. Would you mind giving a hand here? Thank you!

kdokm commented 2 years ago

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

Hi Yinuo, thanks for your work! I think I can try to take over this part.

If the problem is not solved. As Timo mentioned, could you try this url "/shopcarts/" + "?item-id=" + item_id in defining the ajax? where the item_id will be retrieved from the item_id button in UI form, so "let item_id = $("#item_id").val()" and then pass item_id when forming the url

Yes, I have tried Timo's method this morning, unfortunately, as we defined shopcart() as a list, it can not be iterable so this method doesn't work. So I go back to the method we built in routes.py, `@api.doc('list_shopcarts') @api.doc('search_shopcarts') @api.expect(shopcart_args, validate=True) @api.response(200, 'Listed all shopcarts') @api.marshal_list_with(list_shopcart_model) def get(self): """Returns all of the Shopcarts""" app.logger.info("Request for shopcart list") args = shopcart_args.parse_args() if args['item-id']: app.logger.info("Filtering shopcarts by item id %s", args['item-id']) shopcarts = Shopcart.query_by_item_id(args['item-id']) else: app.logger.info("Returning unfiltered shopcart lists") shopcarts = Shopcart.all_shopcart()

    results = [dict(shopcart) for shopcart in shopcarts]
    app.logger.info("Returning %d shopcarts", len(results))
    return results, status.HTTP_200_OK`

But still haven't found any solution. I will really appreciate it if you could find a solution or take this part.

Hi Yinuo, no problem, delegating this part to me, I will try to figure it out tonight or tomorrow.

If it is not solved tonight, I am free to offer helps also.

Hi Yuwen, I am also get stuck at this issue. Would you mind giving a hand here? Thank you!

OK, I will look at it soon.