amochka 0.3.3__tar.gz → 0.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {amochka-0.3.3 → amochka-0.3.4}/PKG-INFO +1 -1
- {amochka-0.3.3 → amochka-0.3.4}/amochka.egg-info/PKG-INFO +1 -1
- {amochka-0.3.3 → amochka-0.3.4}/etl/extractors.py +3 -3
- {amochka-0.3.3 → amochka-0.3.4}/etl/run_etl.py +10 -0
- {amochka-0.3.3 → amochka-0.3.4}/pyproject.toml +1 -1
- {amochka-0.3.3 → amochka-0.3.4}/tests/test_client.py +5 -2
- {amochka-0.3.3 → amochka-0.3.4}/README.md +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka/__init__.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka/client.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka/etl.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka.egg-info/SOURCES.txt +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka.egg-info/dependency_links.txt +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka.egg-info/requires.txt +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/amochka.egg-info/top_level.txt +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/etl/__init__.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/etl/config.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/etl/loaders.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/etl/migrations/001_create_tables.sql +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/etl/transformers.py +0 -0
- {amochka-0.3.3 → amochka-0.3.4}/setup.cfg +0 -0
|
@@ -206,10 +206,10 @@ class AmoCRMExtractor:
|
|
|
206
206
|
|
|
207
207
|
count = 0
|
|
208
208
|
for event in self.client.iter_events(
|
|
209
|
-
|
|
209
|
+
entity=entity_type, # client.py использует 'entity', не 'entity_type'
|
|
210
210
|
event_type=event_types[0] if event_types and len(event_types) == 1 else None,
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
created_from=created_from,
|
|
212
|
+
created_to=created_to,
|
|
213
213
|
):
|
|
214
214
|
# Фильтруем по типам если указано несколько
|
|
215
215
|
if event_types and len(event_types) > 1:
|
|
@@ -199,6 +199,8 @@ def mark_deleted_leads(
|
|
|
199
199
|
loader: PostgresLoader,
|
|
200
200
|
mybi_account_id: int,
|
|
201
201
|
pipeline_ids: Optional[List[int]] = None,
|
|
202
|
+
updated_from: Optional[datetime] = None,
|
|
203
|
+
updated_to: Optional[datetime] = None,
|
|
202
204
|
) -> int:
|
|
203
205
|
"""
|
|
204
206
|
Помечает удалённые сделки в БД (is_deleted = true).
|
|
@@ -206,12 +208,18 @@ def mark_deleted_leads(
|
|
|
206
208
|
Выгружает список удалённых сделок из amoCRM (корзина) и обновляет
|
|
207
209
|
соответствующие записи в БД.
|
|
208
210
|
|
|
211
|
+
Args:
|
|
212
|
+
updated_from: Начало периода (фильтр по deleted_at)
|
|
213
|
+
updated_to: Конец периода (фильтр по deleted_at)
|
|
214
|
+
|
|
209
215
|
Returns:
|
|
210
216
|
Количество помеченных сделок
|
|
211
217
|
"""
|
|
212
218
|
# Выгружаем ID удалённых сделок из amoCRM
|
|
213
219
|
deleted_lead_ids = []
|
|
214
220
|
for lead in extractor.iter_leads(
|
|
221
|
+
updated_from=updated_from,
|
|
222
|
+
updated_to=updated_to,
|
|
215
223
|
pipeline_ids=pipeline_ids,
|
|
216
224
|
only_deleted=True,
|
|
217
225
|
):
|
|
@@ -538,6 +546,8 @@ def run_etl_for_account(
|
|
|
538
546
|
loader,
|
|
539
547
|
mybi_id,
|
|
540
548
|
pipeline_ids=account.pipeline_ids,
|
|
549
|
+
updated_from=leads_updated_from,
|
|
550
|
+
updated_to=updated_to,
|
|
541
551
|
)
|
|
542
552
|
stats["leads_marked_deleted"] = deleted_count
|
|
543
553
|
|
|
@@ -22,9 +22,11 @@ from amochka import (
|
|
|
22
22
|
|
|
23
23
|
class DummyClient(AmoCRMClient):
|
|
24
24
|
def __init__(self):
|
|
25
|
+
import time
|
|
26
|
+
# expires_at как числовой timestamp (через 1 час)
|
|
25
27
|
token_data = {
|
|
26
28
|
"access_token": "x",
|
|
27
|
-
"expires_at": str(
|
|
29
|
+
"expires_at": str(time.time() + 3600)
|
|
28
30
|
}
|
|
29
31
|
super().__init__(
|
|
30
32
|
base_url="https://example.com",
|
|
@@ -249,7 +251,8 @@ def test_export_helpers_write_expected_files(tmp_path):
|
|
|
249
251
|
assert pipelines_lines[0]["entity"] == "pipeline"
|
|
250
252
|
|
|
251
253
|
contacts_call = next(item for item in client.calls if item[1] == "/api/v4/contacts")
|
|
252
|
-
|
|
254
|
+
# API использует filter[id][] для массивов
|
|
255
|
+
assert contacts_call[2].get("filter[id][]") == ["11", "12"] or contacts_call[2].get("filter[id]") == "11,12"
|
|
253
256
|
assert "filter[updated_at][from]" not in contacts_call[2]
|
|
254
257
|
|
|
255
258
|
events_call = next(item for item in client.calls if item[1] == "/api/v4/events")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|