-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop #31
Open
vaibhav-ti
wants to merge
8
commits into
trilogy-group:main
Choose a base branch
from
vaibhav-ti:develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Develop #31
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6c7971d
Added logs for phone-email verification
vaibhav-ti 5dad007
Added logs to sunbmit_lead
vaibhav-ti 540972f
Added logs to lead_conversion
vaibhav-ti 6217879
added log file to db_helper
vaibhav-ti b4a8d91
added exception handling in enrich_lead
vaibhav-ti 9776cef
Added error handling in phone and email verification
vaibhav-ti 0d314c5
Added more exception handling and used module logging
vaibhav-ti 9e9f3bb
Root level logger with mocule level lgger
vaibhav-ti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -9,7 +9,17 @@ | |
""" | ||
what exceptions can be thrown here? | ||
""" | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
def get_enriched_lead_json(adf_json: dict) -> dict: | ||
pass | ||
try: | ||
# process the dict | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is handled here? you can handle keyerror and valueerror in this |
||
|
||
|
||
except KeyError as ke: | ||
logger.error("Key not found in adf_json", ke) | ||
except ValueError as ve: | ||
logger.error("Key can't take this value", ve) | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -13,13 +13,19 @@ | |
You also trying to undderstand the execution time factor. | ||
""" | ||
|
||
# creating a logger | ||
logger = logging.getLogger(__name__) | ||
|
||
async def call_validation_service(url: str, topic: str, value: str, data: dict) -> None: # 2 | ||
if value == '': | ||
logger.info("Value was empty.") | ||
return | ||
logger.info("Calling validation service") | ||
async with httpx.AsyncClient() as client: # 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exception handling missing |
||
response = await client.get(url) | ||
|
||
r = response.json() | ||
logger.debug("Updating the topic in data to json response") | ||
data[topic] = r | ||
|
||
|
||
|
@@ -29,23 +35,48 @@ async def verify_phone_and_email(email: str, phone_number: str) -> bool: | |
ALS_DATA_TOOL_EMAIL_VERIFY_METHOD, | ||
ALS_DATA_TOOL_REQUEST_KEY, | ||
email) | ||
|
||
logger.debug("Email validation url generated.") | ||
|
||
phone_validation_url = '{}?Method={}&RequestKey={}&PhoneNumber={}&OutputFormat=json'.format( | ||
ALS_DATA_TOOL_SERVICE_URL, | ||
ALS_DATA_TOOL_PHONE_VERIFY_METHOD, | ||
ALS_DATA_TOOL_REQUEST_KEY, | ||
phone_number) | ||
|
||
logger.debug("Phone validation url generated.") | ||
|
||
email_valid = False | ||
phone_valid = False | ||
data = {} | ||
|
||
await asyncio.gather( | ||
call_validation_service(email_validation_url, "email", email, data), | ||
call_validation_service(phone_validation_url, "phone", phone_number, data), | ||
logger.info("Calling email validation service.") | ||
try: | ||
call_validation_service(email_validation_url, "email", email, data), | ||
except Exception as e: | ||
logger.error("Error in calling email_validation_service.") | ||
logger.info(e) | ||
|
||
logger.info("Email validation service called.") | ||
logger.info("Calling phone number validation service.") | ||
try: | ||
call_validation_service(phone_validation_url, "phone", phone_number, data), | ||
except Exception as e: | ||
logger.error("Error in calling call_validation_service.") | ||
logger.info(e) | ||
|
||
logger.info("Phone validation service called.") | ||
) | ||
|
||
if "email" in data: | ||
if data["email"]["DtResponse"]["Result"][0]["StatusCode"] in ("0", "1"): | ||
logger.info("Email validated") | ||
email_valid = True | ||
if "phone" in data: | ||
if data["phone"]["DtResponse"]["Result"][0]["IsValid"] == "True": | ||
logger.info("Phone number validated") | ||
phone_valid = True | ||
|
||
logger.debug("Returning the response : whether email is valid or phone number is valid") | ||
return email_valid | phone_valid |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle exceptions wherever external APIs are used in this file.