generated from communitiesuk/funding-service-design-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FS-3535/FS-4340: implementation of the SQS extended client for the as…
…sessment store (#475) * FS-3535: implementation of the SQS extended client for the assessment store * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * FS-3535: implementation of the SQS extended client for the assessment store * FS-3535: addressing review comments and adding util changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> merging since got the approval
- Loading branch information
1 parent
14a555d
commit 1ffe025
Showing
15 changed files
with
943 additions
and
216 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
import json | ||
import threading | ||
|
||
from config.mappings.assessment_mapping_fund_round import fund_round_data_key_mappings | ||
from db.queries import bulk_insert_application_record | ||
from fsd_utils.sqs_scheduler.task_executer_service import TaskExecutorService | ||
|
||
|
||
class AssessmentTaskExecutorService(TaskExecutorService): | ||
def message_executor(self, message): | ||
"""Processing the message in a separate worker thread and this will call | ||
the GOV notify service to send emails :param message Json message.""" | ||
current_thread = threading.current_thread() | ||
thread_id = f"[{current_thread.name}:{current_thread.ident}]" | ||
self.logger.info(f"[{thread_id}] Notification Triggered") | ||
massage_id = message["sqs"]["MessageId"] | ||
try: | ||
application_json = json.loads(message["s3"]) | ||
application_json_list = [] | ||
fund_round_shortname = "".join(application_json["reference"].split("-")[:2]) | ||
# Check if the import config exists for the application | ||
if fund_round_shortname not in fund_round_data_key_mappings.keys(): | ||
self.logger.info.warning(f"Missing import config for the application: {application_json['reference']}.") | ||
return message | ||
|
||
application_json_list.append(application_json) | ||
bulk_insert_application_record(application_json_list, is_json=True) | ||
self.logger.info(f"{thread_id} Processed the message: {massage_id}") | ||
return message | ||
|
||
except Exception as e: | ||
self.logger.error(f"An error occurred while processing the message {massage_id}", e) |
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
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
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 |
---|---|---|
@@ -1 +0,0 @@ | ||
from .aws import _SQS_CLIENT # noqa | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.