Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ddavydov/#12591-sou…
Browse files Browse the repository at this point in the history
…rce-zendesk-support-upd-cdk-version
  • Loading branch information
bazarnov committed May 31, 2022
2 parents 019c7ea + 474349e commit 1794c0a
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
- name: MS SQL Server
destinationDefinitionId: d4353156-9217-4cad-8dd7-c108fd4f74cf
dockerRepository: airbyte/destination-mssql
dockerImageTag: 0.1.17
dockerImageTag: 0.1.18
documentationUrl: https://docs.airbyte.io/integrations/destinations/mssql
icon: mssql.svg
releaseStage: alpha
Expand Down
16 changes: 13 additions & 3 deletions airbyte-config/init/src/main/resources/seed/destination_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@
supportsDBT: false
supported_destination_sync_modes:
- "append"
- dockerImage: "airbyte/destination-mssql:0.1.17"
- dockerImage: "airbyte/destination-mssql:0.1.18"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/destinations/mssql"
connectionSpecification:
Expand Down Expand Up @@ -2473,12 +2473,19 @@
type: "string"
airbyte_secret: true
order: 5
jdbc_url_params:
title: "JDBC URL Params"
description: "Additional properties to pass to the JDBC URL string when\
\ connecting to the database formatted as 'key=value' pairs separated\
\ by the symbol '&'. (example: key1=value1&key2=value2&key3=value3)."
type: "string"
order: 6
ssl_method:
title: "SSL Method"
type: "object"
description: "The encryption method which is used to communicate with the\
\ database."
order: 6
order: 7
oneOf:
- title: "Unencrypted"
additionalProperties: false
Expand All @@ -2489,6 +2496,7 @@
properties:
ssl_method:
type: "string"
const: "unencrypted"
enum:
- "unencrypted"
default: "unencrypted"
Expand All @@ -2502,6 +2510,7 @@
properties:
ssl_method:
type: "string"
const: "encrypted_trust_server_certificate"
enum:
- "encrypted_trust_server_certificate"
default: "encrypted_trust_server_certificate"
Expand All @@ -2516,6 +2525,7 @@
properties:
ssl_method:
type: "string"
const: "encrypted_verify_certificate"
enum:
- "encrypted_verify_certificate"
default: "encrypted_verify_certificate"
Expand All @@ -2524,7 +2534,7 @@
type: "string"
description: "Specifies the host name of the server. The value of\
\ this property must match the subject property of the certificate."
order: 7
order: 8
tunnel_method:
type: "object"
title: "SSH Tunnel Method"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
- name: Facebook Marketing
sourceDefinitionId: e7778cfc-e97c-4458-9ecb-b4f2bba8946c
dockerRepository: airbyte/source-facebook-marketing
dockerImageTag: 0.2.49
dockerImageTag: 0.2.50
documentationUrl: https://docs.airbyte.io/integrations/sources/facebook-marketing
icon: facebook.svg
sourceType: api
Expand Down
19 changes: 18 additions & 1 deletion airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-facebook-marketing:0.2.49"
- dockerImage: "airbyte/source-facebook-marketing:0.2.50"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/facebook-marketing"
changelogUrl: "https://docs.airbyte.io/integrations/sources/facebook-marketing"
Expand Down Expand Up @@ -2141,6 +2141,14 @@
- "2017-01-26T00:00:00Z"
type: "string"
format: "date-time"
insights_lookback_window:
title: "Custom Insights Lookback Window"
description: "The attribution window"
default: 28
maximum: 28
mininum: 1
exclusiveMinimum: 0
type: "integer"
required:
- "name"
page_size:
Expand All @@ -2153,6 +2161,15 @@
order: 7
exclusiveMinimum: 0
type: "integer"
insights_lookback_window:
title: "Insights Lookback Window"
description: "The attribution window"
default: 28
order: 8
maximum: 28
mininum: 1
exclusiveMinimum: 0
type: "integer"
required:
- "account_id"
- "start_date"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION destination-mssql

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.1.17
LABEL io.airbyte.version=0.1.18
LABEL io.airbyte.name=airbyte/destination-mssql
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]


LABEL io.airbyte.version=0.2.49
LABEL io.airbyte.version=0.2.50
LABEL io.airbyte.name=airbyte/source-facebook-marketing
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@
"examples": ["2017-01-26T00:00:00Z"],
"type": "string",
"format": "date-time"
},
"insights_lookback_window": {
"title": "Custom Insights Lookback Window",
"description": "The attribution window",
"default": 28,
"maximum": 28,
"mininum": 1,
"exclusiveMinimum": 0,
"type": "integer"
}
},
"required": ["name"]
Expand All @@ -301,6 +310,16 @@
"order": 7,
"exclusiveMinimum": 0,
"type": "integer"
},
"insights_lookback_window": {
"title": "Insights Lookback Window",
"description": "The attribution window",
"default": 28,
"order": 8,
"maximum": 28,
"mininum": 1,
"exclusiveMinimum": 0,
"type": "integer"
}
},
"required": ["account_id", "start_date", "access_token"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Type[Stream]]:
api = API(account_id=config.account_id, access_token=config.access_token)

insights_args = dict(
api=api,
start_date=config.start_date,
end_date=config.end_date,
api=api, start_date=config.start_date, end_date=config.end_date, insights_lookback_window=config.insights_lookback_window
)
streams = [
AdAccount(api=api),
Expand Down Expand Up @@ -159,6 +157,7 @@ def _update_insights_streams(self, insights: List[InsightConfig], default_args,
time_increment=insight.time_increment,
start_date=insight.start_date or default_args["start_date"],
end_date=insight.end_date or default_args["end_date"],
insights_lookback_window=insight.insights_lookback_window or default_args["insights_lookback_window"],
)
insight_stream = AdsInsights(**args)
insights_custom_streams.append(insight_stream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ class Config:
pattern=DATE_TIME_PATTERN,
examples=["2017-01-26T00:00:00Z"],
)
insights_lookback_window: Optional[PositiveInt] = Field(
title="Custom Insights Lookback Window",
description="The attribution window",
maximum=28,
mininum=1,
default=28,
)


class ConnectorConfig(BaseConfig):
Expand Down Expand Up @@ -156,3 +163,12 @@ class Config:
"Page size used when sending requests to Facebook API to specify number of records per page when response has pagination. Most users do not need to set this field unless they specifically need to tune the connector to address specific issues or use cases."
),
)

insights_lookback_window: Optional[PositiveInt] = Field(
title="Insights Lookback Window",
order=8,
description="The attribution window",
maximum=28,
mininum=1,
default=28,
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class AdsInsights(FBMarketingIncrementalStream):
# HTTP response.
# https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/#overview
INSIGHTS_RETENTION_PERIOD = pendulum.duration(months=37)
# Facebook freezes insight data 28 days after it was generated, which means that all data
# from the past 28 days may have changed since we last emitted it, so we retrieve it again.
INSIGHTS_LOOKBACK_PERIOD = pendulum.duration(days=28)

action_breakdowns = ALL_ACTION_BREAKDOWNS
level = "ad"
Expand All @@ -64,6 +61,7 @@ def __init__(
breakdowns: List[str] = None,
action_breakdowns: List[str] = None,
time_increment: Optional[int] = None,
insights_lookback_window: int = None,
**kwargs,
):
super().__init__(**kwargs)
Expand All @@ -74,6 +72,7 @@ def __init__(
self.breakdowns = breakdowns or self.breakdowns
self.time_increment = time_increment or self.time_increment
self._new_class_name = name
self._insights_lookback_window = insights_lookback_window

# state
self._cursor_value: Optional[pendulum.Date] = None # latest period that was read
Expand All @@ -91,6 +90,16 @@ def primary_key(self) -> Optional[Union[str, List[str], List[List[str]]]]:
"""Build complex PK based on slices and breakdowns"""
return ["date_start", "account_id", "ad_id"] + self.breakdowns

@property
def insights_lookback_period(self):
"""
Facebook freezes insight data 28 days after it was generated, which means that all data
from the past 28 days may have changed since we last emitted it, so we retrieve it again.
But in some cases users my have define their own lookback window, thats
why the value for `insights_lookback_window` is set throught config.
"""
return pendulum.duration(days=self._insights_lookback_window)

def list_objects(self, params: Mapping[str, Any]) -> Iterable:
"""Because insights has very different read_records we don't need this method anymore"""

Expand Down Expand Up @@ -187,7 +196,7 @@ def _generate_async_jobs(self, params: Mapping) -> Iterator[AsyncJob]:
"""

today = pendulum.today(tz="UTC").date()
refresh_date = today - self.INSIGHTS_LOOKBACK_PERIOD
refresh_date = today - self.insights_lookback_period

for ts_start in self._date_intervals():
if ts_start in self._completed_slices:
Expand Down Expand Up @@ -235,13 +244,12 @@ def _get_start_date(self) -> pendulum.Date:
"""
today = pendulum.today(tz="UTC").date()
oldest_date = today - self.INSIGHTS_RETENTION_PERIOD
refresh_date = today - self.INSIGHTS_LOOKBACK_PERIOD

refresh_date = today - self.insights_lookback_period
if self._cursor_value:
start_date = self._cursor_value + pendulum.duration(days=self.time_increment)
if start_date > refresh_date:
logger.info(
f"The cursor value within refresh period ({self.INSIGHTS_LOOKBACK_PERIOD}), start sync from {refresh_date} instead."
f"The cursor value within refresh period ({self.insights_lookback_period}), start sync from {refresh_date} instead."
)
start_date = min(start_date, refresh_date)

Expand All @@ -252,7 +260,6 @@ def _get_start_date(self) -> pendulum.Date:
start_date = self._start_date
if start_date < oldest_date:
logger.warning(f"Loading insights older then {self.INSIGHTS_RETENTION_PERIOD} is not possible. Start sync from {oldest_date}.")

return max(oldest_date, start_date)

def request_params(self, **kwargs) -> MutableMapping[str, Any]:
Expand Down
Loading

0 comments on commit 1794c0a

Please sign in to comment.