Skip to content

Commit

Permalink
✨ Source Bing Ads: add new stream `Campaign Impression Performance Re…
Browse files Browse the repository at this point in the history
…port` (daily, hourly, weekly, monthly) (#32059)

Co-authored-by: artem1205 <artem1205@users.noreply.github.com>
  • Loading branch information
artem1205 and artem1205 authored Nov 3, 2023
1 parent ca9a7c3 commit d0a7a91
Show file tree
Hide file tree
Showing 12 changed files with 742 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ acceptance_tests:
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: campaign_performance_report_hourly
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: campaign_impression_performance_report_hourly
bypass_reason: "Empty report; hourly data fetched is limited to 180 days"
- name: keyword_performance_report_hourly
bypass_reason: "Hourly reports are disabled, because sync is too long"
- name: geographic_performance_report_hourly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,46 @@
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_hourly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_daily",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_weekly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_impression_performance_report_monthly",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "keyword_performance_report_hourly",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 47f25999-dd5e-4636-8c39-e7cea2453331
dockerImageTag: 1.7.1
dockerImageTag: 1.8.0
dockerRepository: airbyte/source-bing-ads
documentationUrl: https://docs.airbyte.com/integrations/sources/bing-ads
githubIssueLabel: source-bing-ads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import ABC, abstractmethod
from datetime import datetime
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional, Union
from typing import Any, Iterable, List, Mapping, MutableMapping, Optional

import pendulum
import source_bing_ads.source
Expand All @@ -14,7 +14,6 @@
from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
from bingads.service_client import ServiceClient
from bingads.v13.internal.reporting.row_report import _RowReport
from bingads.v13.internal.reporting.row_report_iterator import _RowReportRecord
from bingads.v13.reporting import ReportingDownloadParameters
from suds import sudsobject

Expand Down Expand Up @@ -292,28 +291,6 @@ def get_report_request(
report_request.Columns = columns
return report_request

def parse_response(self, response: sudsobject.Object, **kwargs: Mapping[str, Any]) -> Iterable[Mapping]:
if response is not None:
for row in response.report_records:
yield {column: self.get_column_value(row, column) for column in self.report_columns}

yield from []

@staticmethod
def get_column_value(row: _RowReportRecord, column: str) -> Union[str, None, int, float]:
"""
Reads field value from row and transforms:
1. empty values to logical None
2. Percent values to numeric string e.g. "12.25%" -> "12.25"
"""
value = row.value(column)
if not value or value == "--":
return None
if "%" in value:
value = value.replace("%", "")

return value

def get_report_record_timestamp(self, datestring: str) -> int:
"""
Parse report date field based on aggregation type
Expand Down
Loading

0 comments on commit d0a7a91

Please sign in to comment.