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

Source Twilio: shift start date for stream if it exceeds 400 days #15972

Merged
merged 5 commits into from
Aug 29, 2022
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import datetime
from typing import Any, List, Mapping, Tuple

import pendulum
from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
Expand Down Expand Up @@ -67,6 +68,12 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
"lookback_window": config["lookback_window"],
}

# Fix for `Date range specified in query is partially or entirely outside of retention window of 400 days`
# See: https://app.zenhub.com/workspaces/python-connectors-6262f8b593bb82001df56c65/issues/airbytehq/airbyte/10418
incremental_stream_kwargs_message_stream = dict(**incremental_stream_kwargs)
if pendulum.now().diff(pendulum.parse(config["start_date"])).days >= 400:
incremental_stream_kwargs_message_stream["start_date"] = (pendulum.now() - datetime.timedelta(days=399)).to_iso8601_string()

streams = [
Accounts(**full_refresh_stream_kwargs),
Addresses(**full_refresh_stream_kwargs),
Expand All @@ -82,8 +89,8 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
DependentPhoneNumbers(**full_refresh_stream_kwargs),
IncomingPhoneNumbers(**full_refresh_stream_kwargs),
Keys(**full_refresh_stream_kwargs),
MessageMedia(**incremental_stream_kwargs),
Messages(**incremental_stream_kwargs),
MessageMedia(**incremental_stream_kwargs_message_stream),
Messages(**incremental_stream_kwargs_message_stream),
OutgoingCallerIds(**full_refresh_stream_kwargs),
Queues(**full_refresh_stream_kwargs),
Recordings(**incremental_stream_kwargs),
Expand Down