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

feat: Config option to pull data only on specified employers #35

Merged
merged 1 commit into from
Aug 18, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| campaign_status | True | Active | Campaign Status to filter on. Defaults to 'Active' alternatives are ACTIVE, DELETED, PAUSED |
| client_id | True | None | client_id from https://secure.indeed.com/account/apikeys |
| client_secret | True | None | client_secret from https://secure.indeed.com/account/apikeys |
| employer_ids | False | None | List of employer ids to use for children of the employer stream. If left unset, will pull all employer ids. |
| start_date | True | today - 365 days | Defaults to today minus 365, only used for the stats endpointNote that the Campaign Performance Stats stream will only go back a total of 365 days. |
| stream_maps | False | None | Config object for stream maps capability. For more information check out [Stream Maps](https://sdk.meltano.com/en/latest/stream_maps.html). |
| stream_map_config | False | None | User-defined config values to be used within map expressions. |
Expand Down
9 changes: 9 additions & 0 deletions tap_indeedsponsoredjobs/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
return {
"_sdc_employer_id": record["id"],
}

def get_records(self, context: Optional[dict]) -> Iterable[dict]:
"""Return a generator of row-type dictionary objects."""
# If employer_ids is empty, null, or nonexistant, default to using the API to
# determine all employers.
if "employer_ids" in self.config and self.config["employer_ids"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi self.config.get("employer_ids") does what you want here and it's a pit more "pythonic"

return [{"id": id} for id in self.config["employer_ids"]]
else:
return super().get_records(context=context)


class EmployerStatsReport(IndeedSponsoredJobsStream):
Expand Down
9 changes: 9 additions & 0 deletions tap_indeedsponsoredjobs/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ class TapIndeedSponsoredJobs(Tap):
required=True,
description="client_secret from https://secure.indeed.com/account/apikeys",
),
th.Property(
"employer_ids",
th.ArrayType(th.StringType),
required=False,
description=(
"List of employer ids to use for children of the employer stream. If "
"left unset, will pull all employer ids."
),
),
th.Property(
"start_date",
th.StringType,
Expand Down