amochka 0.3.3__tar.gz → 0.3.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amochka
3
- Version: 0.3.3
3
+ Version: 0.3.5
4
4
  Summary: Python library for working with amoCRM API with ETL capabilities
5
5
  Author-email: Timur <timurdt@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amochka
3
- Version: 0.3.3
3
+ Version: 0.3.5
4
4
  Summary: Python library for working with amoCRM API with ETL capabilities
5
5
  Author-email: Timur <timurdt@gmail.com>
6
6
  License: MIT
@@ -206,10 +206,10 @@ class AmoCRMExtractor:
206
206
 
207
207
  count = 0
208
208
  for event in self.client.iter_events(
209
- entity_type=entity_type,
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
- start=created_from,
212
- end=created_to,
211
+ created_from=created_from,
212
+ created_to=created_to,
213
213
  ):
214
214
  # Фильтруем по типам если указано несколько
215
215
  if event_types and len(event_types) > 1:
@@ -255,8 +255,8 @@ class AmoCRMExtractor:
255
255
  for note in self.client.iter_notes(
256
256
  entity=entity_type,
257
257
  note_type=note_type,
258
- start=updated_from,
259
- end=updated_to,
258
+ updated_from=updated_from,
259
+ updated_to=updated_to,
260
260
  ):
261
261
  count += 1
262
262
  if count % 100 == 0:
@@ -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
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "amochka"
7
- version = "0.3.3"
7
+ version = "0.3.5"
8
8
  description = "Python library for working with amoCRM API with ETL capabilities"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -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(int(datetime.utcnow().timestamp()) + 3600)
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
- assert contacts_call[2]["filter[id]"] == "11,12"
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