diff --git a/cg/server/endpoints/pools.py b/cg/server/endpoints/pools.py index e7248dbef6..a799f4dc8a 100644 --- a/cg/server/endpoints/pools.py +++ b/cg/server/endpoints/pools.py @@ -1,9 +1,10 @@ from http import HTTPStatus + from flask import Blueprint, abort, g, jsonify, request from cg.server.endpoints.utils import before_request -from cg.store.models import Customer, Pool from cg.server.ext import db +from cg.store.models import Customer, Pool POOLS_BLUEPRINT = Blueprint("pools", __name__, url_prefix="/api/v1") POOLS_BLUEPRINT.before_request(before_request) diff --git a/cg/store/crud/read.py b/cg/store/crud/read.py index 2b65d0842a..2cd4176291 100644 --- a/cg/store/crud/read.py +++ b/cg/store/crud/read.py @@ -225,17 +225,20 @@ def get_cases_by_customers_action_and_case_search( offset: int = 0, ) -> tuple[list[Case], int]: """ - Retrieve a list of cases filtered by customers, action, and matching names or internal ids. + Return cases by customers, action, and matching names or internal ids, plus the total + number of cases matching the filter criteria. A limit and offset can be applied to the + query for pagination purposes. Args: customers (list[Customer] | None): A list of customer objects to filter cases by. action (str | None): The action string to filter cases by. case_search (str | None): The case search string to filter cases by. - limit (int | None, default=30): The maximum number of cases to return. - offset (int, default=0): The offset to start returning cases by. + limit (int | None, default=50): The maximum number of cases to return. + offset (int, default=0): The offset number of cases for the query. Returns: - tuple[list[Case], int]: A list of filtered cases sorted by creation time and truncated - by the limit parameter, and the total number of samples before truncation. + list[Case]: A list of filtered cases sorted by creation time and truncated + by the limit parameter. + int: The total number of cases returned before truncation. """ filter_functions: list[Callable] = [ CaseFilter.BY_CUSTOMER_ENTRY_IDS, @@ -635,11 +638,11 @@ def get_samples_by_customers_and_pattern( Args: customers (list[Customer] | None): A list of customer objects to filter cases by. pattern (str | None): The sample internal id or name pattern to search for. - limit (int | None, default=30): The maximum number of cases to return. - offset (int, default=0): The offset to start returning cases by. + limit (int | None, default=50): The maximum number of samples to return. + offset (int, default=0): The offset number of samples for the query. Returns: - tuple[list[Sample], int]: A list of filtered samples truncated by the limit parameter - and the total number of samples before truncation. + list[Sample]: A list of filtered samples truncated by the limit parameter. + int: The total number of samples returned before truncation. """ samples: Query = self._get_query(table=Sample) filter_functions: list[SampleFilter] = [] diff --git a/tests/store/crud/read/test_read.py b/tests/store/crud/read/test_read.py index e9c138da7b..66ea7a6012 100644 --- a/tests/store/crud/read/test_read.py +++ b/tests/store/crud/read/test_read.py @@ -1014,7 +1014,6 @@ def test_get_pools_to_render_with( # WHEN fetching pools with no customer or enquiry pools: list[Pool] = store_with_multiple_pools_for_customer.get_pools_to_render() - # THEN two pools should be returned assert len(pools) == 2 @@ -1040,6 +1039,7 @@ def test_get_pools_to_render_with_customer_and_name_enquiry( ): """Test that pools can be fetched from the store by customer id.""" # GIVEN a database with two pools + # WHEN fetching pools by customer id and name enquiry pools: list[Pool] = store_with_multiple_pools_for_customer.get_pools_to_render( customers=store_with_multiple_pools_for_customer.get_customers(), enquiry=pool_name_1 @@ -1057,7 +1057,6 @@ def test_get_pools_to_render_with_customer_and_order_enquiry( # GIVEN a database with two pools # WHEN fetching pools by customer id and order enquiry - pools: list[Pool] = store_with_multiple_pools_for_customer.get_pools_to_render( customers=store_with_multiple_pools_for_customer.get_customers(), enquiry=pool_order_1 )