[copr] search: api: implement search (8d9fd2a)

Miroslav Suchý msuchy at redhat.com
Wed Feb 26 13:11:41 UTC 2014


On 02/17/2014 08:10 AM, ignatenkobrain at fedoraproject.org wrote:
> +
> + at api_ns.route("/coprs/search/")
> + at api_ns.route("/coprs/search/<project>/")
> +def api_coprs_search_by_project(project=None):
> +    """ Return the list of coprs found in search by the given project.
> +    project is taken either from GET params or from the URL itself
> +    (in this order).
> +
> +    :arg project: the project one would like find for coprs.
> +
> +    """
> +    project = flask.request.args.get("project", None) or project
> +    httpcode = 200
> +    if project:
> +        query = coprs_logic.CoprsLogic.get_multiple(
> +            flask.g.user, coprname=project)
> +
> +        repos = query.all()
> +        output = {"output": "ok", "users": []}
> +        for repo in repos:
> +            output["users"].append({"name": repo.owner})
> +    else:
> +        output = {"output": "notok", "error": "Invalid request"}
> +        httpcode = 500
> +
> +    jsonout = flask.jsonify(output)
> +    jsonout.status_code = httpcode
> +    return jsonout

Hmm, I would expect that this api call would do fulltext search using whooshe.
Same as /coprs/fulltext/ in WebUI.

-- 
Miroslav Suchy, RHCE, RHCDS
Red Hat, Senior Software Engineer, #brno, #devexp, #fedora-buildsys


More information about the copr-devel mailing list