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 SurveyMonkey: fix add missing params to stream survey_responses #25109

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2026,7 +2026,7 @@
- name: SurveyMonkey
sourceDefinitionId: badc5925-0485-42be-8caa-b34096cb71b5
dockerRepository: airbyte/source-surveymonkey
dockerImageTag: 0.1.16
dockerImageTag: 0.1.17
documentationUrl: https://docs.airbyte.com/integrations/sources/surveymonkey
icon: surveymonkey.svg
sourceType: api
Expand Down
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.16
LABEL io.airbyte.version=0.1.17
LABEL io.airbyte.name=airbyte/source-surveymonkey
Expand Up @@ -3,7 +3,7 @@ test_strictness_level: high
acceptance_tests:
spec:
tests:
- spec_path: "source_surveymonkey/spec.json"
- spec_path: "source_surveymonkey/spec.json"
connection:
tests:
- config_path: "secrets/config_old.json"
Expand All @@ -14,20 +14,20 @@ acceptance_tests:
status: "failed"
discovery:
tests:
- config_path: "secrets/config.json"
- config_path: "secrets/config.json"
basic_read:
tests:
- config_path: "secrets/config.json"
expect_records:
path: "integration_tests/expected_records.txt"
fail_on_extra_columns: false
- config_path: "secrets/config.json"
expect_records:
path: "integration_tests/expected_records.txt"
fail_on_extra_columns: false
incremental:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"

Large diffs are not rendered by default.

Expand Up @@ -110,7 +110,6 @@ def parse_response(self, response: requests.Response, stream_state: Mapping[str,


class IncrementalSurveymonkeyStream(SurveymonkeyStream, ABC):

state_checkpoint_interval = 1000

@property
Expand All @@ -128,7 +127,6 @@ def get_updated_state(self, current_stream_state: MutableMapping[str, Any], late


class SurveyIds(IncrementalSurveymonkeyStream):

cursor_field = "date_modified"

def path(self, **kwargs) -> str:
Expand All @@ -137,7 +135,7 @@ def path(self, **kwargs) -> str:
def request_params(self, stream_state: Mapping[str, Any], **kwargs) -> MutableMapping[str, Any]:
params = super().request_params(stream_state=stream_state, **kwargs)
params["sort_order"] = "ASC"
params["sort_by"] = "date_modified"
params["sort_by"] = self.cursor_field
params["per_page"] = 1000 # maybe as user input or bigger value
since_value = pendulum.parse(stream_state.get(self.cursor_field)) if stream_state.get(self.cursor_field) else self._start_date

Expand Down Expand Up @@ -219,7 +217,7 @@ def parse_response(self, response: requests.Response, stream_state: Mapping[str,

class SurveyResponses(SurveyIDSliceMixin, IncrementalSurveymonkeyStream):
"""
Docs: https://developer.surveymonkey.com/api/v3/#survey-responses
Docs: https://developer.surveymonkey.com/api/v3/#api-endpoints-survey-responses
"""

cursor_field = "date_modified"
Expand Down Expand Up @@ -249,8 +247,18 @@ def get_updated_state(self, current_stream_state: MutableMapping[str, Any], late
current_stream_state[survey_id] = {self.cursor_field: state_value}
return current_stream_state

def request_params(self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, **kwargs) -> MutableMapping[str, Any]:
params = super().request_params(stream_state=stream_state, **kwargs)
def request_params(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
) -> MutableMapping[str, Any]:
if next_page_token:
return next_page_token

params = super().request_params(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token)
params["sort_order"] = "ASC"
params["sort_by"] = self.cursor_field
# Max of 100 allowed per page. We use the highest
# possible value to reduce the number of API calls.
params["per_page"] = 100

since_value_surv = stream_state.get(stream_slice["survey_id"])
if since_value_surv:
Expand Down
Expand Up @@ -375,11 +375,11 @@ def test_surveys_responses_get_updated_state(current_stream_state, latest_record
[
(
{"307785415": {"date_modified": "2021-01-01T00:00:00+00:00"}},
{"start_modified_at": "2021-01-01T00:00:00"},
{"sort_order": "ASC", "sort_by": "date_modified", "per_page": 100, "start_modified_at": "2021-01-01T00:00:00"},
),
(
{},
{"start_modified_at": "2000-01-01T00:00:00"}, # return start_date
{"sort_order": "ASC", "sort_by": "date_modified", "per_page": 100, "start_modified_at": "2000-01-01T00:00:00"}, # return start_date
),
],
)
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/surveymonkey.md
Expand Up @@ -65,7 +65,8 @@ To cover more data from this source we use caching.

| Version | Date | Pull Request | Subject |
|:--------| :--------- | :------------------------------------------------------- | :--------------------------------------------------------------------- |
| 0.1.16 | 2023-04-13 | [25080](https://github.com/airbytehq/airbyte/pull/25080) | Fix spec.json required fields and update schema for surveys and survey_responses |
| 0.1.17 | 2023-04-17 | [25109](https://github.com/airbytehq/airbyte/pull/25109) | Fix add missing params to stream `SurveyResponses` |
| 0.1.16 | 2023-04-13 | [25080](https://github.com/airbytehq/airbyte/pull/25080) | Fix spec.json required fields and update schema for surveys and survey_responses |
| 0.1.15 | 2023-02-11 | [22865](https://github.com/airbytehq/airbyte/pull/22865) | Specified date formatting in specification |
| 0.1.14 | 2023-01-27 | [22024](https://github.com/airbytehq/airbyte/pull/22024) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| 0.1.13 | 2022-11-29 | [19868](https://github.com/airbytehq/airbyte/pull/19868) | Fix OAuth flow urls |
Expand Down