Add APM (#184)
* Add APM * Fix unit tests * Remove apm.py * Add SonarCloud recommendations * SonarCloud python:S6890
This commit is contained in:
@ -1,9 +1,18 @@
|
||||
import requests
|
||||
import sentry_sdk
|
||||
|
||||
from app.utils.config import config
|
||||
|
||||
|
||||
def __n8n_post(data: dict) -> bool:
|
||||
"""Post data to N8N webhook URL.
|
||||
|
||||
Args:
|
||||
data (dict): Data to post to webhook URL.
|
||||
|
||||
Returns:
|
||||
bool: True if successful, else False.
|
||||
"""
|
||||
headers: dict = {"Content-Type": "application/json"}
|
||||
resp: requests.Response = requests.post(
|
||||
url=config.n8n_webhook_url,
|
||||
@ -16,22 +25,45 @@ def __n8n_post(data: dict) -> bool:
|
||||
|
||||
|
||||
def submit_task(summary, description, completion_date, requestor) -> bool:
|
||||
data: dict = {
|
||||
"requestor": requestor,
|
||||
"title": summary,
|
||||
"description": description,
|
||||
"completiondate": completion_date,
|
||||
}
|
||||
return __n8n_post(data=data)
|
||||
"""Submit task to N8N webhook URL.
|
||||
|
||||
Args:
|
||||
summary (str): Summary of task.
|
||||
description (str): Description of task.
|
||||
completion_date (str): Completion date of task.
|
||||
requestor (str): Requestor of task.
|
||||
|
||||
Returns:
|
||||
bool: True if successful, else False.
|
||||
"""
|
||||
with sentry_sdk.start_transaction(name="submit_task"):
|
||||
data: dict = {
|
||||
"requestor": requestor,
|
||||
"title": summary,
|
||||
"description": description,
|
||||
"completiondate": completion_date,
|
||||
}
|
||||
_data = __n8n_post(data=data)
|
||||
return _data
|
||||
|
||||
|
||||
def get_tasks(requestor) -> bool:
|
||||
headers: dict = {"Content-Type": "application/json"}
|
||||
resp: requests.Response = requests.get(
|
||||
url=config.n8n_webhook_url,
|
||||
headers=headers,
|
||||
timeout=10,
|
||||
verify=False,
|
||||
params={"requestor": requestor},
|
||||
)
|
||||
return bool(resp.status_code == 200)
|
||||
"""Get tasks from N8N webhook URL.
|
||||
|
||||
Args:
|
||||
requestor (str): Requestor of tasks.
|
||||
|
||||
Returns:
|
||||
bool: True if successful, else False.
|
||||
"""
|
||||
with sentry_sdk.start_transaction(name="get_tasks"):
|
||||
headers: dict = {"Content-Type": "application/json"}
|
||||
resp: requests.Response = requests.get(
|
||||
url=config.n8n_webhook_url,
|
||||
headers=headers,
|
||||
timeout=10,
|
||||
verify=False,
|
||||
params={"requestor": requestor},
|
||||
)
|
||||
_data = bool(resp.status_code == 200)
|
||||
return _data
|
||||
|
Reference in New Issue
Block a user