예제 #1
0
파일: annotations.py 프로젝트: maticanzic/h
def search(request):
    """Search the database for annotations matching with the given query."""
    schema = SearchParamsSchema()
    params = validate_query_params(schema, request.params)

    separate_replies = params.pop("_separate_replies", False)

    stats = getattr(request, "stats", None)

    search = search_lib.Search(request,
                               separate_replies=separate_replies,
                               stats=stats)
    result = search.run(params)

    svc = request.find_service(name="annotation_json_presentation")

    out = {
        "total": result.total,
        "rows": svc.present_all(result.annotation_ids)
    }

    if separate_replies:
        out["replies"] = svc.present_all(result.reply_ids)

    return out
예제 #2
0
def search(request):
    """Search the database for annotations matching with the given query."""
    schema = SearchParamsSchema()
    params = validate_query_params(schema, request.params)

    _record_search_api_usage_metrics(params)

    separate_replies = params.pop('_separate_replies', False)

    stats = getattr(request, 'stats', None)

    search = search_lib.Search(request,
                               separate_replies=separate_replies,
                               stats=stats)
    search.append_modifier(
        UriCombinedWildcardFilter(request, separate_keys=True))
    result = search.run(params)

    svc = request.find_service(name='annotation_json_presentation')

    out = {
        'total': result.total,
        'rows': svc.present_all(result.annotation_ids)
    }

    if separate_replies:
        out['replies'] = svc.present_all(result.reply_ids)

    return out
예제 #3
0
 def schema(self):
     return SearchParamsSchema()