-
Notifications
You must be signed in to change notification settings - Fork 0
Sync changes formkeep #2
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
Changes from 13 commits
709a17d
7756597
905e446
21c160f
a1e5410
745d083
01a6d1a
24f7d1a
46b69ba
5aee33e
34affa4
c4fc0af
8289a8b
a98b741
6439506
85e8b25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,2 @@ | ||
| from tap_formkeep.streams.submissions import Submissions | ||
|
|
||
| STREAMS = { | ||
| "submissions": Submissions, | ||
| } | ||
|
|
||
| STREAMS = {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ class BaseStream(ABC): | |
|
|
||
| url_endpoint = "" | ||
| path = "" | ||
| page_size = 25 | ||
| page = 25 | ||
|
||
| next_page_key = "next_page" | ||
| headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} | ||
| children = [] | ||
|
|
@@ -43,7 +43,8 @@ def __init__(self, client=None, catalog=None) -> None: | |
| self.schema = catalog.schema.to_dict() | ||
| self.metadata = metadata.to_map(catalog.metadata) | ||
| self.child_to_sync = [] | ||
| self.params = {'api_token': 'api_token', 'page': 1, 'page_limit': 25, 'spam': 'False', 'startdate': ''} | ||
| self.page_size = self.client.config.get("page_size", self.page) | ||
| self.params = {'page': 1, 'page_limit': self.page_size} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. made the change for this |
||
| self.data_payload = {} | ||
|
|
||
| @property | ||
|
|
@@ -99,21 +100,32 @@ def sync( | |
|
|
||
| def get_records(self) -> Iterator: | ||
| """Interacts with api client interaction and pagination.""" | ||
| self.params[""] = self.page_size | ||
| next_page = 1 | ||
| while next_page: | ||
| self.params["page"] = 1 | ||
| response = self.client.make_request( | ||
| self.http_method, | ||
| self.url_endpoint, | ||
| self.params, | ||
| body=json.dumps(self.data_payload), | ||
| path=self.path | ||
| ) | ||
mukeshbhatt18gl marked this conversation as resolved.
Show resolved
Hide resolved
mukeshbhatt18gl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| raw_records = response.get(self.data_key, []) | ||
| pagination = response.get("meta", {}).get("pagination", {}) | ||
| total_pages = pagination.get("total_pages", 1) | ||
|
|
||
| for record in raw_records: | ||
| yield record | ||
| for page in range(2, total_pages + 1): | ||
| self.params["page"] = page | ||
|
|
||
| response = self.client.make_request( | ||
| self.http_method, | ||
| self.url_endpoint, | ||
| self.params, | ||
| self.headers, | ||
| body=json.dumps(self.data_payload), | ||
| path=self.path | ||
| ) | ||
| raw_records = response.get(self.data_key, []) | ||
| next_page = response.get(self.next_page_key) | ||
|
|
||
| self.params[self.next_page_key] = next_page | ||
| yield from raw_records | ||
|
|
||
| def write_schema(self) -> None: | ||
|
|
@@ -132,6 +144,12 @@ def update_params(self, **kwargs) -> None: | |
| """ | ||
| Update params for the stream | ||
| """ | ||
| default = { | ||
| "page": 1, | ||
| "page_limit": self.page_size | ||
| } | ||
|
|
||
| self.params = {**default, **self.params} | ||
| self.params.update(kwargs) | ||
|
|
||
| def update_data_payload(self, **kwargs) -> None: | ||
|
|
@@ -150,7 +168,7 @@ def get_url_endpoint(self, parent_obj: Dict = None) -> str: | |
| """ | ||
| Get the URL endpoint for the stream | ||
| """ | ||
| return self.url_endpoint or f"{self.client.base_url}/{self.path}" | ||
| return self.url_endpoint or self.client.base_url.format(form_id=self.path) | ||
|
|
||
|
|
||
| class IncrementalStream(BaseStream): | ||
|
|
@@ -189,8 +207,7 @@ def sync( | |
| """Implementation for `type: Incremental` stream.""" | ||
| bookmark_date = self.get_bookmark(state, self.tap_stream_id) | ||
| current_max_bookmark_date = bookmark_date | ||
| self.update_params(updated_since=bookmark_date) | ||
| self.update_data_payload(parent_obj=parent_obj) | ||
| self.update_params(startdate=bookmark_date) | ||
mukeshbhatt18gl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.url_endpoint = self.get_url_endpoint(parent_obj) | ||
|
|
||
| with metrics.record_counter(self.tap_stream_id) as counter: | ||
|
|
@@ -299,4 +316,3 @@ def get_bookmark(self, state: Dict, stream: str, key: Any = None) -> int: | |
| self.bookmark_value = super().get_bookmark(state, stream) | ||
|
|
||
| return self.bookmark_value | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.