Skip to content

Commit

Permalink
try to reduce the amount of accounts synced by removing accounts with…
Browse files Browse the repository at this point in the history
… amount_spent=0 (empty accounts
  • Loading branch information
NahidOulmi committed Dec 21, 2023
1 parent ddfe3a0 commit 366f06e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"streams": [
{
"stream": {
"name": "ads_insights",
"name": "activities",
"json_schema": {},
"supported_sync_modes": [
"full_refresh",
Expand All @@ -14,7 +14,19 @@
},
{
"stream": {
"name": "activities",
"name": "ad_account",
"json_schema": {},
"supported_sync_modes": [
"full_refresh",
"incremental"
]
},
"sync_mode": "incremental",
"destination_sync_mode": "append"
},
{
"stream": {
"name": "ads_insights",
"json_schema": {},
"supported_sync_modes": [
"full_refresh",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,16 @@ def accounts(self) -> List[AdAccount]:
ad_accounts = []

business = facebook_business.adobjects.business.Business(fbid="1605818716400473")
accounts = business.get_owned_ad_accounts(fields=["name", "account_id"])
accounts = business.get_owned_ad_accounts(
fields=["name", "account_id", "amount_spent", "account_status"])
for account in accounts:
account_id = account.get("account_id")
if account.get("amount_spent") == "0":
logger.info("Not syncing account ID {} because the amount_spent is 0".format(account_id))
continue
if account.get("account_status") == "101":
logger.info("Not syncing account ID {} because the account_status is 101 (deleted)".format(account_id))
continue
account_name = account["name"]
if "geoloc" in str.lower(account_name):
account["dolead_type"] = "GEOLOC"
Expand Down

0 comments on commit 366f06e

Please sign in to comment.