Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lambdas/services/base/dynamo_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ def query_table_with_paginator(
limit: int = 20,
page_size: int = 1,
start_key: str | None = None,
scan_index_forward: bool | None = None,
) -> dict:

try:
Expand All @@ -528,6 +529,9 @@ def query_table_with_paginator(
"PaginationConfig": pagination_config,
}

if scan_index_forward is not None:
query_params["ScanIndexForward"] = scan_index_forward

if expression_attribute_values is None:
expression_attribute_values = {}

Expand Down
1 change: 1 addition & 0 deletions lambdas/services/document_reference_search_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def get_paginated_references_by_nhs_number(
filter_expression=filter_expression,
expression_attribute_names=condition_attribute_names,
expression_attribute_values=condition_attribute_values,
scan_index_forward=False,
)

logger.info("Validating upload status")
Expand Down
2 changes: 2 additions & 0 deletions lambdas/services/document_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def query_table_with_paginator(
index_name: str,
search_key: str,
search_condition: str,
scan_index_forward: bool | None = None,
table_name: str | None = None,
filter_expression: str | None = None,
expression_attribute_names: dict | None = None,
Expand All @@ -393,6 +394,7 @@ def query_table_with_paginator(
limit=limit,
page_size=page_size,
start_key=start_key,
scan_index_forward=scan_index_forward,
)

references = [
Expand Down
3 changes: 3 additions & 0 deletions lambdas/tests/unit/services/base/test_dynamo_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from boto3.dynamodb.conditions import And, Attr, Equals, Key
from botocore.exceptions import ClientError

from enums.dynamo_filter import AttributeOperator
from enums.metadata_field_names import DocumentReferenceMetadataFields
from services.base.dynamo_service import DynamoDBService
Expand Down Expand Up @@ -1521,6 +1522,7 @@ def test_query_table_using_paginator(mock_service):
index_name="NhsNumberIndex",
key="NhsNumber",
condition=TEST_NHS_NUMBER,
scan_index_forward=False,
)

mock_paginator.paginate.assert_called_with(
Expand All @@ -1529,6 +1531,7 @@ def test_query_table_using_paginator(mock_service):
KeyConditionExpression="NhsNumber=:i",
ExpressionAttributeValues={":i": {"S": TEST_NHS_NUMBER}},
PaginationConfig={"MaxItems": 20, "PageSize": 1},
ScanIndexForward=False,
)

assert actual == expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ def test_get_paginated_references_by_nhs_number_returns_references_and_token(
filter_expression="#Deleted_attr = :Deleted_condition_val OR attribute_not_exists(#Deleted_attr)",
expression_attribute_names={"#Deleted_attr": "Deleted"},
expression_attribute_values={":Deleted_condition_val": ""},
scan_index_forward=False,
)

assert actual == expected
Expand Down Expand Up @@ -561,6 +562,7 @@ def test_get_paginated_references_by_nhs_number_handles_filters(mock_document_se
":Deleted_condition_val": "",
":DocStatus_condition_val": "final",
},
scan_index_forward=False,
)


Expand Down
Loading
Loading