limits
This commit is contained in:
parent
07d8062d8b
commit
7b1027cc95
13
app/main.py
13
app/main.py
|
@ -39,12 +39,14 @@ statuses = {
|
|||
"7": "Отклонено",
|
||||
}
|
||||
|
||||
|
||||
# Создаем кастомный фильтр для форматирования дат
|
||||
def format_status(value):
|
||||
value = str(value)
|
||||
res = statuses[value] if value in statuses else value
|
||||
return res
|
||||
|
||||
|
||||
# Регистрируем фильтр в Jinja2Templates
|
||||
templates.env.filters["format_status"] = format_status
|
||||
templates.env.filters["format_datetime"] = format_datetime
|
||||
|
@ -172,9 +174,16 @@ async def deal_tab(
|
|||
"STATUS",
|
||||
"GROUP_ID",
|
||||
]
|
||||
get_task_hook = f"{WEBHOOK}/tasks.task.list?{'&'.join([f'select[]={s}' for s in select])}&filter[UF_CRM_TASK]=D_{deal_id}&limit=100"
|
||||
get_task_hook = f"{WEBHOOK}/tasks.task.list?{'&'.join([f'select[]={s}' for s in select])}&filter[UF_CRM_TASK]=D_{deal_id}"
|
||||
task_data = requests.get(get_task_hook)
|
||||
task_data_json = task_data.json()
|
||||
result = task_data_json["result"]["tasks"]
|
||||
|
||||
while len(task_data_json["tasks"]) == 50 or len(result) > 50*4:
|
||||
limit = ((result//50) + 1) * 50
|
||||
task_data = requests.get(get_task_hook + f"limit={limit}")
|
||||
task_data_json = task_data.json()
|
||||
result += task_data_json["result"]["tasks"]
|
||||
|
||||
# logger.info(task_data_json["result"]["tasks"])
|
||||
parts = WEBHOOK.split("/")
|
||||
|
@ -182,7 +191,7 @@ async def deal_tab(
|
|||
return templates.TemplateResponse(
|
||||
request=request,
|
||||
name="deal_tab.html",
|
||||
context={"tasks": task_data_json["result"]["tasks"], "domain": domain},
|
||||
context={"tasks": result, "domain": domain},
|
||||
)
|
||||
|
||||
return {"status": "success", "result": task_data_json}
|
||||
|
|
Loading…
Reference in New Issue