コード例 #1
0
def test_spending_by_transaction_count(monkeypatch, transaction_type_data, elasticsearch_transaction_index):
    setup_elasticsearch_test(monkeypatch, elasticsearch_transaction_index)

    request_data = {"filters": {"keywords": ["pop tart"]}}
    results = spending_by_transaction_count(request_data)
    expected_results = {"contracts": 1, "grants": 1, "idvs": 1, "loans": 1, "direct_payments": 1, "other": 1}
    assert results == expected_results
コード例 #2
0
ファイル: search.py プロジェクト: kristen178/usaspending-api
    def post(self, request):

        models = [{'name': 'keyword', 'key': 'filters|keyword', 'type': 'text', 'text_type': 'search', 'min': 3}]
        validated_payload = TinyShield(models).block(request.data)

        results = spending_by_transaction_count(validated_payload)
        if not results:
            raise ElasticsearchConnectionException('Error during the aggregations')
        return Response({"results": results})
コード例 #3
0
    def post(self, request):

        models = [{
            "name": "keywords",
            "key": "filters|keywords",
            "type": "array",
            "array_type": "text",
            "text_type": "search",
            "optional": False,
            "text_min": 3,
        }]
        validated_payload = TinyShield(models).block(request.data)
        results = spending_by_transaction_count(validated_payload)
        return Response({"results": results})
コード例 #4
0
    def post(self, request):

        models = [{
            "name": "keywords",
            "key": "filters|keywords",
            "type": "array",
            "array_type": "text",
            "text_type": "search",
            "optional": False,
            "text_min": 3,
        }]
        validated_payload = TinyShield(models).block(request.data)
        results = spending_by_transaction_count(validated_payload)
        if not results:
            raise ElasticsearchConnectionException(
                "Error during the aggregations")
        return Response({"results": results})