From 48ad610e20a15d9614b101ad63f7db6bcd97469d Mon Sep 17 00:00:00 2001 From: PhilipWafula Date: Mon, 3 May 2021 23:43:07 +0300 Subject: [PATCH] Moves query for user metadata higher up the application layer. --- apps/cic-ussd/cic_ussd/operations.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/cic-ussd/cic_ussd/operations.py b/apps/cic-ussd/cic_ussd/operations.py index ea66825d..5f2ca7a2 100644 --- a/apps/cic-ussd/cic_ussd/operations.py +++ b/apps/cic-ussd/cic_ussd/operations.py @@ -325,6 +325,14 @@ def process_menu_interaction_requests(chain_str: str, # get user user = Account.session.query(Account).filter_by(phone_number=phone_number).first() + # retrieve and cache user's metadata + blockchain_address = user.blockchain_address + s_query_person_metadata = celery.signature( + 'cic_ussd.tasks.metadata.query_person_metadata', + [blockchain_address] + ) + s_query_person_metadata.apply_async(queue='cic-ussd') + # find any existing ussd session existing_ussd_session = UssdSession.session.query(UssdSession).filter_by( external_session_id=external_session_id).first()