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
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})
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})
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})