Skip to content

Commit

Permalink
Merge pull request #177 from cfpb/remove-map-hits
Browse files Browse the repository at this point in the history
Remove unneeded hits from map-tab requests
  • Loading branch information
higs4281 authored Aug 6, 2021
2 parents 92a4c78 + 0218609 commit 13f4ea2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion complaint_search/es_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def document(complaint_id):
def states_agg(agg_exclude=None, **kwargs):
params = copy.deepcopy(PARAMS)
params.update(**kwargs)
params.update({'size': 500})
params.update({'size': 0})
search_builder = SearchBuilder()
search_builder.add(**params)
body = search_builder.build()
Expand Down
14 changes: 1 addition & 13 deletions complaint_search/tests/expected_results/states_agg__valid.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"size": 500,
"size": 0,
"track_total_hits": true,
"_source": [
"company",
Expand All @@ -22,18 +22,6 @@
"timely",
"zip_code"
],
"highlight": {
"require_field_match": false,
"number_of_fragments": 1,
"fragment_size": 500,
"fields": {
"complaint_what_happened": {}
}
},
"sort": [
{"_score": {"order": "desc"}},
{"_id": "desc"}
],
"aggs": {
"issue": {
"filter": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"size": 500,
"size": 0,
"track_total_hits": true,
"_source": [
"company",
Expand All @@ -22,18 +22,6 @@
"timely",
"zip_code"
],
"highlight": {
"require_field_match": false,
"number_of_fragments": 1,
"fragment_size": 500,
"fields": {
"complaint_what_happened": {}
}
},
"sort": [
{"_score": {"order": "desc"}},
{"_id": "desc"}
],
"aggs": {
"issue": {
"filter": {
Expand Down
13 changes: 13 additions & 0 deletions complaint_search/tests/test_views_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from complaint_search.serializer import SearchInputSerializer
from complaint_search.throttling import (
_CCDB_UI_URL,
CCDBAnonRateThrottle,
ExportAnonRateThrottle,
ExportUIRateThrottle,
SearchAnonRateThrottle,
Expand Down Expand Up @@ -783,6 +784,18 @@ def test_search_with_search_anon_rate_throttle(self, mock_essearch):
self.assertEqual(limit, mock_essearch.call_count)
self.assertEqual(20, limit)

@override_settings(DEBUG=False)
@mock.patch('complaint_search.es_interface.search')
@mock.patch.object(CCDBAnonRateThrottle, 'is_referred_from_ui')
def test_search_is_referred(self, mock_ccdb_is_referred, mock_essearch):
url = reverse('complaint_search:search')
mock_essearch.return_value = 'OK'
SearchAnonRateThrottle.rate = self.orig_search_anon_rate
mock_ccdb_is_referred.return_value = True
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual('OK', response.data)

@override_settings(DEBUG=True)
@mock.patch('complaint_search.es_interface.search')
def test_search_with_anon_rate_throttle_debug(self, mock_essearch):
Expand Down

0 comments on commit 13f4ea2

Please sign in to comment.