Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rabidaudio committed Sep 1, 2021
1 parent c956686 commit fda828b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ all the tables for you, and avoids having to sample the data to determine the sc
```javascript
{
"start_date": "2015-01-01T00:00:00Z",
// A path to a JSON credentials file for a service account. Make sure
// you give that user permissions by inviting them to your Play Store
// account and giving them "View app information and download bulk reports (read-only)"
// and "View financial data, orders, and cancellation survey responses" permissions.
// A path to a JSON credentials file for a service account. Make sure you give that
// user permissions by inviting them to your Play Store account and giving them
// "View app information and download bulk reports (read-only)" and
// "View financial data, orders, and cancellation survey responses" permissions.
// These permissions must be granted account-wide, not just for one app.
// It can take a few hours before the grant takes effect.
"credentials_path": "./client_secret.json",
// The path to the bucket Google sends reports to. You can get this from the
// "Copy Cloud Storage URI" button from the reports page.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
py_modules=["tap_playstore"],
install_requires=[
'singer-python>=5.12.1',
'tap-gcs-csv @ git+https://github.com/fixdauto/tap-gcs-csv.git@9cb3c67561ba4a67512526e064248ba018695db3',
'tap-gcs-csv @ git+https://github.com/fixdauto/tap-gcs-csv.git@v0.0.3',
],
entry_points="""
[console_scripts]
Expand Down
31 changes: 22 additions & 9 deletions tap_playstore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,22 @@ def get_abs_path(path):
"search_prefix": "sales",
"format": "csv",
"encoding": "utf-8",
"compression": "zip"
"compression": "zip",
"schema_overrides": {
# these number fields have commas in them, and float("1,000.00") does not work.
"item_price": {
"type": ["null", "string"],
"_conversion_type": "string"
},
"taxes_collected": {
"type": ["null", "string"],
"_conversion_type": "string"
},
"charged_amount": {
"type": ["null", "string"],
"_conversion_type": "string"
}
}
},
"earnings": {
"pattern": "earnings/earnings_.*\\.zip",
Expand All @@ -47,10 +62,7 @@ def get_abs_path(path):
"schema_overrides": {
# force post code to be treated as a string instead of an integer
"buyer_postal_code": {
"type": [
"null",
"string"
],
"type": ["null", "string"],
"_conversion_type": "string"
}
}
Expand Down Expand Up @@ -82,9 +94,9 @@ def get_abs_path(path):
"encoding": "utf-16"
}

def discover():
def discover(cached=True):
# return the cached catalog
if os.getenv('TAP_PLAYSTORE_GENERATE_CATALOG') != 'true':
if cached:
return Catalog.load(get_abs_path('cached_catalog.json'))
# This generates the catalog using tap-gcs-csv sampling
# and caches it to the tap.
Expand All @@ -107,15 +119,16 @@ def main():
# Parse command line arguments
args = singer.utils.parse_args(REQUIRED_CONFIG_KEYS)

cached_catalog = args.config.get('cached_catalog', True)
if args.discover:
catalog = discover()
catalog = discover(cached_catalog)
catalog.dump()
# Otherwise run in sync mode
else:
if args.catalog:
catalog = args.catalog
else:
catalog = discover()
catalog = discover(cached_catalog)

tap_gcs_csv.do_sync(args.config, args.state, catalog)

Expand Down
12 changes: 6 additions & 6 deletions tap_playstore/cached_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,19 +709,19 @@
"item_price": {
"type": [
"null",
"number"
"string"
]
},
"taxes_collected": {
"type": [
"null",
"number"
"string"
]
},
"charged_amount": {
"type": [
"null",
"number"
"string"
]
},
"city_of_buyer": {
Expand Down Expand Up @@ -898,7 +898,7 @@
],
"metadata": {
"inclusion": "available",
"conversion_type": "number"
"conversion_type": "string"
}
},
{
Expand All @@ -908,7 +908,7 @@
],
"metadata": {
"inclusion": "available",
"conversion_type": "number"
"conversion_type": "string"
}
},
{
Expand All @@ -918,7 +918,7 @@
],
"metadata": {
"inclusion": "available",
"conversion_type": "number"
"conversion_type": "string"
}
},
{
Expand Down

0 comments on commit fda828b

Please sign in to comment.