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 Facebook Marketing: Videos stream remove filtering #21385

Merged
merged 4 commits into from
Jan 13, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
- name: Facebook Marketing
sourceDefinitionId: e7778cfc-e97c-4458-9ecb-b4f2bba8946c
dockerRepository: airbyte/source-facebook-marketing
dockerImageTag: 0.2.82
dockerImageTag: 0.2.83
documentationUrl: https://docs.airbyte.com/integrations/sources/facebook-marketing
icon: facebook.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-facebook-marketing:0.2.82"
- dockerImage: "airbyte/source-facebook-marketing:0.2.83"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/facebook-marketing"
changelogUrl: "https://docs.airbyte.com/integrations/sources/facebook-marketing"
Expand Down
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.82
LABEL io.airbyte.version=0.2.83
LABEL io.airbyte.name=airbyte/source-facebook-marketing
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from airbyte_cdk.sources.utils.transform import TransformConfig, TypeTransformer
from cached_property import cached_property
from facebook_business.adobjects.abstractobject import AbstractObject
from facebook_business.adobjects.adimage import AdImage
from facebook_business.api import FacebookAdsApiBatch, FacebookRequest, FacebookResponse

from .common import deep_merge
Expand Down Expand Up @@ -243,6 +242,9 @@ def _state_filter(self, stream_state: Mapping[str, Any]) -> Mapping[str, Any]:
"""Don't have classic cursor filtering"""
return {}

def get_record_deleted_status(self, record) -> bool:
return False

def read_records(
self,
sync_mode: SyncMode,
Expand All @@ -261,7 +263,7 @@ def read_records(
record_cursor_value = pendulum.parse(record[self.cursor_field])
if self._cursor_value and record_cursor_value < self._cursor_value:
break
if not self._include_deleted and record[AdImage.Field.status] == AdImage.Status.deleted:
if not self._include_deleted and self.get_record_deleted_status(record):
continue

self._max_cursor_value = self._max_cursor_value or record_cursor_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from cached_property import cached_property
from facebook_business.adobjects.abstractobject import AbstractObject
from facebook_business.adobjects.adaccount import AdAccount as FBAdAccount
from facebook_business.adobjects.adimage import AdImage
from facebook_business.adobjects.user import User

from .base_insight_streams import AdsInsights
Expand Down Expand Up @@ -145,13 +146,14 @@ def _state_filter(self, stream_state: Mapping[str, Any]) -> Mapping[str, Any]:
return {"since": since.int_timestamp}


class Videos(FBMarketingIncrementalStream):
class Videos(FBMarketingReversedIncrementalStream):
"""See: https://developers.facebook.com/docs/marketing-api/reference/video"""

entity_prefix = "video"

def list_objects(self, params: Mapping[str, Any]) -> Iterable:
return self._api.account.get_ad_videos(params=params)
# Remove filtering as it is not working for this stream since 2023-01-13
return self._api.account.get_ad_videos(params=params, fields=self.fields)


class AdAccount(FBMarketingStream):
Expand Down Expand Up @@ -194,6 +196,9 @@ class Images(FBMarketingReversedIncrementalStream):
def list_objects(self, params: Mapping[str, Any]) -> Iterable:
return self._api.account.get_ad_images(params=params, fields=self.fields)

def get_record_deleted_status(self, record) -> bool:
return record[AdImage.Field.status] == AdImage.Status.deleted


class AdsInsightsAgeAndGender(AdsInsights):
breakdowns = ["age", "gender"]
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/facebook-marketing.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Please be informed that the connector uses the `lookback_window` parameter to pe

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.2.83 | 2023-01-13 | [21149](https://github.com/airbytehq/airbyte/pull/21149) | Videos stream remove filtering |
| 0.2.82 | 2023-01-09 | [21149](https://github.com/airbytehq/airbyte/pull/21149) | Fix AdAccount schema |
| 0.2.81 | 2023-01-05 | [21057](https://github.com/airbytehq/airbyte/pull/21057) | Remove unsupported fields from request |
| 0.2.80 | 2022-12-21 | [20736](https://github.com/airbytehq/airbyte/pull/20736) | Fix update next cursor |
Expand Down