canonical / certification.ubuntu.com

1 stars 14 forks source link

Searching by Vendor using a comma delimited list does not work with the API #179

Closed codersquid closed 3 years ago

codersquid commented 3 years ago

Here are the problematic code snippets in views.py

    vendors = (
            ",".join(request.args.getlist("vendor"))
            if request.args.getlist("vendor")
            else None
        )
        models_response = api.certified_models(
            category__in=forms,
            major_release__in=releases,
            vendor=vendors,
            query=query,
            offset=offset,
        )

The API does not handle the vendor query parameter with comma delimited lists. Instead, vendor should be repeated with all of the vendors being filtered. e.g. to search for Lenovo and Dell machines this query would be used:

https://certification.staging.canonical.com/api/v1/certifiedmodels/?format=json&vendor=Lenovo&vendor=Dell

codersquid commented 3 years ago

To clarify, currently if someone searches for more than one vendor, no results will be returned because the backend will see the "foo,bar" string as the name of one vendor and find no records for it.

this request should return 4 results, but it returns nothing.

/certification?text=&form=SoC&vendor=Applied+Micro+Circuits+Corp.&vendor=Qualcomm+Inc&filters=True

carkod commented 3 years ago

Closed by https://github.com/canonical-web-and-design/ubuntu.com/pull/9600