-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow efficient deep pagination to 10K hits
This change sets the default initial pagination depth to 100 for fast initial searches, but allows users to explore as deeply as they dare by progressively increasing the pagination depth by another 100 hits, as needed, up to 10K. Searches will lose tiny amounts of speed as pagination goes deeper, maxing out at around 6 seconds per "next page" request when a theoretical user approaches 10,000 hits under the sea. This scheme also enables the saving of search URLs with a pagination "page" number that will reproduce the search. Testing You can test the deep pagination locally if you have a local complaint index populated in Docker or local Elasticsearch. Docker If you're running cfgov in Docker, you can clone ccdb5-api into the develop-apps folder and checkint out this branch. Virtual env If you're running cfgov in a virtual environment: - Activate your cfgov virtual environment - Clone the ccdb5-api repo to a folder of your choice - Check out this branch, and then use `pip install -e .` to inject the branch into your virtual env. We can also deploy the code to a DEV server for CA testing.
- Loading branch information
Showing
5 changed files
with
96 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
from complaint_search.defaults import MAX_PAGINATION_DEPTH, PAGINATION_BATCH | ||
from complaint_search.es_interface import get_pagination_query_size | ||
|
||
|
||
class TestPaginationSize(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.user_sizes = [10, 25, 50, 100] | ||
|
||
def test_get_pagination_query_size_page_1(self): | ||
page = 1 | ||
for user_size in self.user_sizes[:3]: | ||
self.assertEqual( | ||
get_pagination_query_size(page, user_size), | ||
PAGINATION_BATCH * 2 | ||
) | ||
self.assertEqual( | ||
get_pagination_query_size(page, 400), | ||
600 | ||
) | ||
|
||
def test_get_pagination_query_size_page_2(self): | ||
page = 2 | ||
self.assertEqual( | ||
get_pagination_query_size(page, 25), | ||
PAGINATION_BATCH * 2 | ||
) | ||
self.assertEqual( | ||
get_pagination_query_size(page, 100), | ||
PAGINATION_BATCH * 4 | ||
) | ||
|
||
def test_get_pagination_query_size_with_remainder(self): | ||
page = 6 | ||
self.assertEqual( | ||
get_pagination_query_size(page, 25), | ||
PAGINATION_BATCH * 4 | ||
) | ||
|
||
def test_get_pagination_query_size_equals_max(self): | ||
page = 100 | ||
self.assertEqual( | ||
get_pagination_query_size(page, 100), | ||
MAX_PAGINATION_DEPTH | ||
) | ||
|
||
def test_get_pagination_query_size_exceeds_max(self): | ||
page = 101 | ||
self.assertEqual( | ||
get_pagination_query_size(page, 100), | ||
MAX_PAGINATION_DEPTH | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters