Skip to content

Commit

Permalink
Added a surrogate key for the report data
Browse files Browse the repository at this point in the history
  • Loading branch information
justedro committed Jun 3, 2019
1 parent f677c62 commit 799755d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
34 changes: 5 additions & 29 deletions tap_appstore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,9 @@ def discover():
# TODO Events may have a different key property than this. Change
# if it's appropriate.
'key_properties': [
'provider',
'provider_country',
'sku',
'developer',
'title',
'version',
'product_type_identifier',
'developer_proceeds',
'line_id', # artificial
'begin_date',
'end_date',
'customer_currency',
'country_code',
'currency_of_proceeds',
'apple_identifier',
'customer_price',
'promo_code',
'parent_identifier',
'subscription',
'period',
'category',
'cmb',
'device',
'supported_platforms',
'proceeds_reason',
'preserved_pricing',
'client',
'order_type'
'end_date'
]
}
streams.append(catalog_entry)
Expand All @@ -141,7 +117,7 @@ def tsv_to_list(tsv, column_name_modifier = None):
line_cols = line.split('\t')
for i, column in enumerate(header):
if i < len(line_cols):
line_obj[column] = line_cols[i]
line_obj[column] = line_cols[i].strip()
data.append(line_obj)

return data
Expand Down Expand Up @@ -177,9 +153,9 @@ def query_report(api):
rep_tsv = api.sales_report('SALES', 'SUMMARY', 'DAILY', Context.config['vendor'], iterator_str, '1_0')
rep = tsv_to_list(rep_tsv)

for line in rep:
for index, line in enumerate(rep, start=1):
data = line

data['line_id'] = index
rec = transformer.transform(data, stream_schema)

singer.write_record(
Expand Down
6 changes: 6 additions & 0 deletions tap_appstore/schemas/summary_sales_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"object"
],
"properties": {
"line_id": {
"type": [
"null",
"integer"
]
},
"provider": {
"type": [
"null",
Expand Down

0 comments on commit 799755d

Please sign in to comment.