Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exclusions to match the second set of pairs in docs #56

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tap_bing_ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,17 @@ def metadata_fn(report_name, field, required_fields):
mdata = {"metadata": {"inclusion": "available"}, "breadcrumb": ["properties", field]}

if EXCLUSIONS.get(report_name):
if field in EXCLUSIONS[report_name]['Attributes']:
mdata['metadata']['fieldExclusions'] = [['properties', p] for p in EXCLUSIONS[report_name]['ImpressionSharePerformanceStatistics']]
if field in EXCLUSIONS[report_name]['ImpressionSharePerformanceStatistics']:
mdata['metadata']['fieldExclusions'] = [['properties', p] for p in EXCLUSIONS[report_name]['Attributes']]
for group_set in EXCLUSIONS[report_name]:
if field in group_set['Attributes']:
mdata['metadata']['fieldExclusions'] = [
*mdata['metadata'].get('fieldExclusions', []),
*[['properties', p] for p in group_set['ImpressionSharePerformanceStatistics']]
]
if field in group_set['ImpressionSharePerformanceStatistics']:
mdata['metadata']['fieldExclusions'] = [
*mdata['metadata'].get('fieldExclusions', []),
*[['properties', p] for p in group_set['Attributes']]
]

return mdata

Expand Down
212 changes: 137 additions & 75 deletions tap_bing_ads/exclusions.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,138 @@
"""
Defines the field exclusion rules for Bing Ads/Microsoft Ads reports.
The structure is for each report, there are groups of fields that cannot
be selected with the associated group.

Docs: https://docs.microsoft.com/en-us/advertising/guides/reports?view=bingads-13#columnrestrictions

"""

EXCLUSIONS = {
'AccountPerformanceReport': {
'Attributes': [
'BidMatchType',
'DeviceOS',
'TopVsOther'
],
'ImpressionSharePerformanceStatistics': [
'AbsoluteTopImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
},
'AdGroupPerformanceReport': {
'Attributes': [
'BidMatchType',
'DeviceOS',
'TopVsOther',
'Goal',
'GoalType'
],
'ImpressionSharePerformanceStatistics': [
'AbsoluteTopImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
},
'CampaignPerformanceReport': {
'Attributes': [
'BidMatchType',
'DeviceOS',
'TopVsOther',
'BudgetAssociationStatus',
'BudgetName',
'BudgetStatus'
],
'ImpressionSharePerformanceStatistics': [
'AbsoluteTopImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
},
'ProductDimensionPerformanceReport': {
'AccountPerformanceReport': [
{
'Attributes': [
'CustomerId',
'CustomerName',
'DeliveredMatchType'
],
'ImpressionSharePerformanceStatistics': [
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent'
]
},
{
'Attributes': [
'BidMatchType',
'DeviceOS',
'Goal',
'GoalType',
'TopVsOther'
],
'ImpressionSharePerformanceStatistics': [
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent',
'AbsoluteTopImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionLostToRankAggPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
}],
'AdGroupPerformanceReport': [
{
'Attributes': [
'CustomerId',
'CustomerName',
'DeliveredMatchType'
],
'ImpressionSharePerformanceStatistics': [
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent'
]
},{
'Attributes': [
'BidMatchType',
'DeviceOS',
'TopVsOther',
'Goal',
'GoalType'
],
'ImpressionSharePerformanceStatistics': [
'AbsoluteTopImpressionSharePercent',
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionLostToRankAggPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
}],
'CampaignPerformanceReport': [
{
'Attributes': [
'CustomerId',
'CustomerName',
'DeliveredMatchType'
],
'ImpressionSharePerformanceStatistics': [
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent'
]
},{
'Attributes': [
'BidMatchType',
'DeviceOS',
'Goal',
'GoalType',
'TopVsOther',
'BudgetAssociationStatus',
'BudgetName',
'BudgetStatus'
],
'ImpressionSharePerformanceStatistics': [
'AudienceImpressionLostToBudgetPercent',
'AudienceImpressionLostToRankPercent',
'AudienceImpressionSharePercent',
'AbsoluteTopImpressionSharePercent',
'ClickSharePercent',
'ExactMatchImpressionSharePercent',
'ImpressionLostToAdRelevancePercent',
'ImpressionLostToBidPercent',
'ImpressionLostToBudgetPercent',
'ImpressionLostToExpectedCtrPercent',
'ImpressionLostToRankPercent',
'ImpressionLostToRankAggPercent',
'ImpressionSharePercent',
'TopImpressionRatePercent',
'TopImpressionShareLostToBudgetPercent',
'TopImpressionShareLostToRankPercent',
'TopImpressionSharePercent'
]
}],
'ProductDimensionPerformanceReport': [{
'Attributes': [
'AdDistribution',
'AdId',
Expand All @@ -90,8 +152,8 @@
'ImpressionLostToRankPercent',
'ImpressionSharePercent'
]
},
'ProductPartitionPerformanceReport': {
}],
'ProductPartitionPerformanceReport': [{
'Attributes': [
'AdDistribution',
'AdId',
Expand All @@ -113,5 +175,5 @@
'ImpressionLostToRankPercent',
'ImpressionSharePercent'
]
}
}]
}