From 7bcfcc458c0f7b5b98064f4d0c29548a2ef9c5f3 Mon Sep 17 00:00:00 2001 From: jsdio Date: Mon, 5 Jun 2023 15:39:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=83=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D1=83=D1=81=D0=BF=D0=B5=D1=88=D0=BD=D1=8B=D0=B9=20ID=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BE=D0=BA=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20LAST=5FID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.dist | 3 ++- extractor.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env.dist b/.env.dist index 399e1c7..c33ea61 100644 --- a/.env.dist +++ b/.env.dist @@ -3,4 +3,5 @@ API_TOKEN=jmkdjsfopjsef IBLOCKS=1,2,3 DESTINATION_HOST=127.0.0.1 DESTINATION_PORT=8000 -DESTINATION_PROTOCOL=http \ No newline at end of file +DESTINATION_PROTOCOL=http +LAST_ID=0 \ No newline at end of file diff --git a/extractor.py b/extractor.py index 9ab4960..bbbbab9 100644 --- a/extractor.py +++ b/extractor.py @@ -1,5 +1,7 @@ import logging import json +import os + import aiohttp import backoff from environs import load_dotenv @@ -30,7 +32,7 @@ class ApiExtractor: else: data['fields'] = json.dumps(self.fields + ["PROPERTY_*"], ensure_ascii=False) - min_id = state.get_state(f'iblock_{iblock_id}') or 0 + min_id = state.get_state(f'iblock_{iblock_id}') or os.getenv('LAST_ID') or 0 data['bitrFilter'] = json.dumps({'>ID': str(min_id)}, ensure_ascii=False) abitrs = []