Skip to content

Commit

Permalink
Deprecate list_and_get()
Browse files Browse the repository at this point in the history
  • Loading branch information
leshchenko1979 committed Mar 3, 2024
1 parent cd1708d commit 5485116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ contacts = b.get_by_ID(
Обратите внимание, что метод `get_all()` не может быть использован в сочетнии с группой методов REST API, начинающихся с `task.elapseditem.*`.

### Метод `list_and_get(self, method_branch: str, ID_field_name='ID') -> dict`
>**!!! Метод устарел в связи с изменениями политики по ограничению скорости запросов Битрикса и будет удален в будущих версиях.**
Скачать список всех ID при помощи метода `method_branch + '.list'`,
а затем значения всех полей всех элементов при помощи метода `method_branch + '.get'`. `method_branch` - группа методов, в которой есть подметоды `*.list` и `*.get`, например `crm.lead`.

Expand Down
13 changes: 8 additions & 5 deletions fast_bitrix24/user_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import re
import warnings
from collections import ChainMap
from beartype.typing import Dict, Any, Iterable, Union
from beartype import beartype

import icontract
from beartype import beartype
from beartype.typing import Any, Dict, Iterable, Union

from . import logger
from .mult_request import (
MultipleServerRequestHandler,
MultipleServerRequestHandlerPreserveIDs,
Expand Down Expand Up @@ -210,16 +211,14 @@ def check_special_limitations(self):
async def run(self) -> dict:
self.prepare_item_list()

results = await MultipleServerRequestHandlerPreserveIDs(
return await MultipleServerRequestHandlerPreserveIDs(
self.bitrix,
self.method,
self.item_list,
ID_field=self.ID_field_name,
get_by_ID=True,
).run()

return results

def prepare_item_list(self):
if self.params:
self.item_list = [
Expand Down Expand Up @@ -306,6 +305,10 @@ def __init__(self, bitrix, method_branch: str, ID_field_name: str = "ID"):
self.method_branch = method_branch
self.ID_field_name = ID_field_name

logger.warning(
"list_and_get(): 'ListAndGetUserRequest' is deprecated. Use 'get_all()' instead."
)

@icontract.require(
lambda self: not re.search(
r"(\.list|\.get)$", self.method_branch.strip().lower()
Expand Down

0 comments on commit 5485116

Please sign in to comment.