Skip to content

Commit

Permalink
combine loops for syncing selected streams
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantgray committed Jan 21, 2025
1 parent acbcf6f commit c6eb3be
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions tap_klaviyo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,20 @@ def load_shared_schema_refs():
def do_sync(config, state, catalog, headers):
start_date = config['start_date'] if 'start_date' in config else None

stream_ids_to_sync = set()

for stream in catalog.get('streams'):
mdata = metadata.to_map(stream['metadata'])
if metadata.get(mdata, (), 'selected'):
stream_ids_to_sync.add(stream['tap_stream_id'])

for stream in catalog['streams']:
if stream['tap_stream_id'] not in stream_ids_to_sync:
continue
singer.write_schema(
stream['stream'],
stream['schema'],
stream['key_properties']
)
singer.write_schema(
stream['stream'],
stream['schema'],
stream['key_properties']
)

if stream['stream'] in EVENT_MAPPINGS.values():
get_incremental_pull(stream, ENDPOINTS['events'], state,
headers, start_date)
else:
get_full_pulls(stream, ENDPOINTS[stream['stream']], headers)
if stream['stream'] in EVENT_MAPPINGS.values():
get_incremental_pull(stream, ENDPOINTS['events'], state,
headers, start_date)
else:
get_full_pulls(stream, ENDPOINTS[stream['stream']], headers)


def get_available_metrics(headers):
Expand Down

0 comments on commit c6eb3be

Please sign in to comment.