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

api/collection/<collection_id>/collections routes GET all entries` returns empty erray even if the entry does not exist #8

Closed
vantage-ola opened this issue Dec 19, 2023 · 2 comments · Fixed by #13
Labels
bug Something isn't working important features needs to be worked on asap

Comments

@vantage-ola
Copy link
Owner

#python3 `\backend\app.py`
list_of_drivers_id= [laptime_dict.get('driver_id') for laptime_dict in tracks_laptime_dicts

        # Use $in to find tracks with matching track_ids
drivers = db.drivers.find({'id': {'$in': list_of_drivers_id}}, {'_id': False})
driver_dicts = [driver for driver in drivers]
if drivers:
        # Convert the result to a list of dictionaries
    return jsonify(driver_dicts)
        #else wouldnt even work, it rathers returns empty array 

if the entry doesnt exist, we should return 'entry not found'. it returns [ ], when querying the server.

@vantage-ola vantage-ola added bug Something isn't working important features needs to be worked on asap labels Dec 19, 2023
@vantage-ola vantage-ola moved this to Backlog in TRACK NOW 🏁 Dec 19, 2023
@Dozie2001
Copy link
Contributor

Why is the condition ?

 if drivers:
        # Convert the result to a list of dictionaries
    return jsonify(driver_dicts)
``` and not:
``` python
 if driver_dicts:
        # Convert the result to a list of dictionaries
    return jsonify(driver_dicts) 

Since driver_dicts is a list of drivers it would check the condition will check if the driver exist with the id(indirectly) exit if not and the list is empty it would return "Entry not found"

@vantage-ola
Copy link
Owner Author

Why is the condition ?

 if drivers:
        # Convert the result to a list of dictionaries
    return jsonify(driver_dicts)
``` and not:
``` python
 if driver_dicts:
        # Convert the result to a list of dictionaries
    return jsonify(driver_dicts) 

Since driver_dicts is a list of drivers it would check the condition will check if the driver exist with the id(indirectly) exit if not and the list is empty it would return "Entry not found"

yeah you are very correct, i will work on implementing the fix 👍

@vantage-ola vantage-ola moved this from Backlog to In progress in TRACK NOW 🏁 Dec 22, 2023
@vantage-ola vantage-ola linked a pull request Dec 22, 2023 that will close this issue
vantage-ola added a commit that referenced this issue Dec 22, 2023
* fix-only-models-to-dict

* revert-back-to-old-laptime

* fix/issue#8
@github-project-automation github-project-automation bot moved this from In progress to Done in TRACK NOW 🏁 Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important features needs to be worked on asap
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants