Skip to content

Commit f248210

Browse files
HGI-8599: Fix counter value issue in sync_stream (#171)
1 parent 5b5852d commit f248210

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

tap_quickbooks/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def do_sync(qb, catalog, state, state_passed):
256256
catalog_entry['tap_stream_id'],
257257
'version',
258258
stream_version)
259-
counter = sync_stream(qb, catalog_entry, state, state_passed)
260-
LOGGER.info("%s: Completed sync (%s rows)", stream_name, counter.value)
259+
counter_value = sync_stream(qb, catalog_entry, state, state_passed)
260+
LOGGER.info("%s: Completed sync (%s rows)", stream_name, counter_value)
261261

262262
state["current_stream"] = None
263263
singer.write_state(state)
@@ -334,4 +334,4 @@ def main():
334334

335335
if __name__ == "__main__":
336336
atexit.register(cleanup)
337-
main()
337+
main()

tap_quickbooks/quickbooks/rest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _sync_records(self, url, headers, params, stream):
108108

109109
query = params['query']
110110

111-
def sync_records(query):
111+
def sync_records(query, is_deleted=False):
112112
offset = 0
113113
max = 100
114114
page = 0
@@ -122,8 +122,12 @@ def sync_records(query):
122122
# Establish number of records returned.
123123
count = resp_json['QueryResponse'].get('maxResults', 0)
124124

125-
# Make sure there is alteast one record.
125+
# Make sure there is at least one record.
126126
if count == 0:
127+
if is_deleted:
128+
LOGGER.info(f"Response (deleted) with no data {resp_json}")
129+
else:
130+
LOGGER.info(f"Response with no data {resp_json}")
127131
break;
128132

129133
page += 1
@@ -147,4 +151,4 @@ def sync_records(query):
147151
query_deleted = query.replace("WHERE", "where Active = false and")
148152
else:
149153
query_deleted = f"{query} where Active = false"
150-
yield from sync_records(query_deleted)
154+
yield from sync_records(query_deleted, is_deleted=True)

tap_quickbooks/sync.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def get_stream_version(catalog_entry, state):
6060

6161
def sync_stream(qb, catalog_entry, state, state_passed):
6262
stream = catalog_entry['stream']
63+
counter_value = 0
6364

6465
with metrics.record_counter(stream) as counter:
6566
try:
@@ -76,7 +77,9 @@ def sync_stream(qb, catalog_entry, state, state_passed):
7677
raise Exception("Error syncing {}: {}".format(
7778
stream, ex)) from ex
7879

79-
return counter
80+
counter_value = counter.value
81+
82+
return counter_value
8083

8184

8285
def sync_records(qb, catalog_entry, state, counter, state_passed):

0 commit comments

Comments
 (0)