Skip to content

Commit

Permalink
refactor: fga-eps-mds/2020.2-Lend.it#138 Refactored get requests filt…
Browse files Browse the repository at this point in the history
…ered by category route

Co-authored-by: Thiago Mesquita <thiago099carvalho@gmail.com>
Co-authored-by: Mateus Maia <mateusmaiamaia@hotmail.com>
  • Loading branch information
3 people committed Apr 23, 2021
1 parent 1e028ac commit 38d8ece
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions project/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,24 @@ def get_all_available_requests():
return jsonify(response), 200


@request_blueprint.route("/requests/<productcategoryid>", methods=["GET"])
def get_filtered_request(productcategoryid):
@request_blueprint.route("/requests/available/<productcategoryid>", methods=["GET"])
def get_requests_filtered_by_category(productcategoryid):
usermail = request.args.get("usermail")

today_date = datetime.now()
today_date = today_date.replace(hour=0, minute=0, second=0, microsecond=0)
today_date.isoformat()

error_response = {"status": "fail", "message": "Request not found"}

requests = get_category_name(
[
request.to_json()
for request in Request.query.filter_by(
productcategoryid=productcategoryid
for request in Request.query.filter(
Request.lender == None,
Request.requester != usermail,
Request.enddate >= today_date,
Request.productcategoryid == productcategoryid,
).all()
]
)
Expand Down

0 comments on commit 38d8ece

Please # to comment.