File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -172,10 +172,15 @@ def get_nhs_numbers_based_on_ods_code(
172172 ) -> list [str ]:
173173 """Get unique NHS numbers for patients with given ODS code."""
174174 table_name = table_name or self .table_name
175- filter_expression = Attr ("Author" ).eq (ods_code ) & Attr ("FileName" ).begins_with (
176- "2of" ,
177- )
178175 projection_expression = "NhsNumber"
176+ if ods_code == "ALL" :
177+ filter_expression = Attr ("FileName" ).begins_with (
178+ "2of" ,
179+ )
180+ else :
181+ filter_expression = Attr ("Author" ).eq (ods_code ) & Attr ("FileName" ).begins_with (
182+ "2of" ,
183+ )
179184
180185 logger .info ("Starting scan of table for NHS numbers based on ODS code..." )
181186 results = self .dynamo_service .scan_whole_table (
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ def retrieve_multipart_references(
5959 )
6060
6161 if doc_type == SupportedDocumentTypes .LG :
62- if any ("1of1 " in result .file_name for result in document_references ):
62+ if any ("1of1_ " in result .file_name for result in document_references ):
6363 logger .error (
6464 "There is already a stitched LG document reference present in DynamoDb"
6565 )
Original file line number Diff line number Diff line change @@ -117,13 +117,16 @@ def get_new_access_token(self):
117117 self .access_token = response .json ()["accessToken" ]
118118
119119 self .update_ssm_access_token (self .access_token )
120- except Exception as e :
121- # ignore TooManyRequests exception as it will be handled by the retry mechanism in request_virus_scan
120+ except ClientError as e :
121+ # ignore TooManyRequests error as it will be handled by the retry mechanism in request_virus_scan
122122 # this is to prevent a scenario where multiple concurrent Lambda executions all attempt to refresh the token at the same time,
123123 # resulting in a flood of requests to the token endpoint and subsequent failures. By ignoring the TooManyRequests exception,
124124 # we allow the retry mechanism to handle the situation gracefully without overwhelming the token service.
125- if str (e ).find ("TooManyRequests" ) != - 1 :
125+ if "TooManyRequests" in str (e ):
126+ logger .info ("Failed to store token in SSM, too many requests, starting retry" )
126127 return
128+
129+ except Exception as e :
127130 logger .error (
128131 f"{ LambdaError .VirusScanNoToken .to_str ()} : { str (e )} " ,
129132 {"Result" : FAIL_SCAN },
You can’t perform that action at this time.
0 commit comments