:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 4 missing tables to the Rippling source (#119118)
Tom Owers33bab6143aba
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 0495a9b12aa1..ae572948290f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -10213,10 +10213,10 @@ Today (9): `companies`, `compensations`, `departments`, `employment_types`, `levDiffed against: <https://developer.rippling.com/sitemap.xml>-- [ ] `list-time-entries (and get-time-entries)` — clock-in/clock-out records - the highest-volume fact table in Rippling and the basis of all labor analysis (high)-- [ ] `list-leave-requests` — time-off requests with status and dates, the core absence dataset (high)-- [ ] `list-worker-payroll-records` — per-worker payroll line items - actual pay, taxes and deductions, not just contracted compensation (high)-- [ ] `list-payroll-runs` — the payroll period header that payroll records roll up to (high)+- [x] `list-time-entries (and get-time-entries)` — clock-in/clock-out records - the highest-volume fact table in Rippling and the basis of all labor analysis (high)+- [x] `list-leave-requests` — time-off requests with status and dates, the core absence dataset (high)+- [x] `list-worker-payroll-records` — per-worker payroll line items - actual pay, taxes and deductions, not just contracted compensation (high)+- [x] `list-payroll-runs` — the payroll period header that payroll records roll up to (high)- [ ] `list-worker-changes (and list-worker-change-fields)` — the transition history for workers - promotions, transfers, terminations; today only current state is synced (high)- [ ] `list-leave-balances (and list-leave-accruals)` — accrued and remaining balance per worker per policy, the standard PTO liability metric (high)- [ ] `list-titles` — lookup resolving the job title ID carried on workers (high)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/canonical_descriptions.pyindex 4c2d3802390b..f6d66252a128 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/canonical_descriptions.py@@ -127,4 +127,88 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {effective_date="Date the compensation took effect.",),},+ "time_entries": {+ "description": "A time entry recording when a worker clocked in and out, with breaks, shifts and pay segments.",+ "docs_url": "https://developer.rippling.com/documentation/rest-api/reference/list-time-entries",+ "columns": _columns(+ worker_id="ID of the worker associated with the time entry.",+ start_time="The start time of the time entry.",+ end_time="The end time of the time entry.",+ comments="The comments associated with the time entry.",+ job_shifts="The job shifts worked during the time entry.",+ breaks="The breaks taken during the time entry.",+ premiums="The premiums earned during the time entry.",+ piece_rate_premiums="The piece-rate premiums earned during the time entry.",+ segments="The pay rates for each segment of the time entry.",+ time_entry_summary="A summary of the time entry.",+ time_card_id="ID of the time card associated with the time entry.",+ tags="The tags associated with the time entry.",+ idempotency_key="The unique key of the time entry in an outside system.",+ create_extra_hours_run="Whether the time entry should create an extra hours run.",+ status="The status of the time entry.",+ pay_period="The pay period associated with the time card.",+ shift_input_values="Arbitrary shift inputs collected on the time entry.",+ ),+ },+ "leave_requests": {+ "description": "A request by a worker for time off, with its dates, status and review details.",+ "docs_url": "https://developer.rippling.com/documentation/rest-api/reference/list-leave-requests",+ "columns": _columns(+ worker_id="ID of the worker associated with the leave request.",+ requester_id="ID of the worker who requested the leave.",+ status="The status of the leave request.",+ start_date="The start date of the leave request.",+ start_time="The start time of the leave request.",+ end_date="The end date of the leave request.",+ end_time="The end time of the leave request.",+ comments="The comments associated with the leave request.",+ number_of_minutes_requested="The number of minutes requested.",+ leave_policy_id="ID of the leave policy associated with the leave request.",+ leave_type_id="ID of the leave type associated with the leave request.",+ leave_event_id="ID of the leave event associated with the leave request, if any.",+ reason_for_leave="The reason for the leave request.",+ reviewer_id="ID of the worker who reviewed the leave request.",+ reviewed_at="Time at which the leave request was reviewed.",+ days_take_off="The specific dates taken off and the amount of time taken off on each one.",+ is_managed_by_external_system="Whether the leave request is managed by an external system.",+ ),+ },+ "payroll_runs": {+ "description": "A payroll run: one pay period's payroll for a company entity, with its dates and state.",+ "docs_url": "https://developer.rippling.com/documentation/rest-api/reference/list-payroll-runs",+ "columns": {+ "id": "Unique identifier for the payroll run.",+ "run_state": "Current state of the run (e.g. DRAFT, APPROVED, PAID).",+ "run_type": "Type of the run (e.g. REGULAR, OFF_CYCLE, CORRECTION).",+ "check_date": "Date the paycheck is issued.",+ "debit_date": "Date funds are debited from the company's account.",+ "title": "Human-readable title of the payroll run.",+ "approval_deadline": "Deadline for approving the payroll run.",+ "approved_at": "Time at which the run was approved.",+ "paid_at": "Time at which the run was marked as paid.",+ "lock_deadline": "Deadline after which the run is locked for changes.",+ "pay_period": "Pay period details for the run.",+ "company_entity_id": "ID of the company legal entity the payroll run belongs to.",+ "country_code": "ISO country code where the payroll run applies.",+ "payment_type": "Payment method used (e.g. WIRE, ACH).",+ },+ },+ "worker_payroll_records": {+ "description": "A worker's payroll record within a payroll run: gross and net pay, earnings, taxes, deductions and garnishments.",+ "docs_url": "https://developer.rippling.com/documentation/rest-api/reference/list-worker-payroll-records",+ "columns": {+ "id": "Unique identifier for the payroll record.",+ "run_id": "ID of the payroll run the record belongs to.",+ "worker_id": "ID of the worker the record belongs to.",+ "currency": "ISO currency code for the monetary amounts in the record.",+ "country_code": "ISO country code where the payroll record applies.",+ "net_pay": "Net pay amount for the period.",+ "gross_pay": "Gross pay amount for the period.",+ "summary": "Aggregate totals for taxes, deductions and garnishments.",+ "earnings": "List of earning line items.",+ "taxes": "List of tax line items.",+ "deductions": "List of deduction line items.",+ "garnishments": "List of garnishment line items.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/rippling.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/rippling.pyindex 23220e313925..a991026c1855 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/rippling.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/rippling.py@@ -1,34 +1,43 @@-import dataclassesfrom datetime import UTC, date, datetimefrom typing import Any, Optionalfrom urllib.parse import urlencode, urljoin, urlsplitfrom requests import Response+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_sessionfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (RESTAPIConfig,rest_api_resource,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ build_dependent_resource,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (BaseNextUrlPaginator,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfigfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse-from products.warehouse_sources.backend.temporal.data_imports.sources.rippling.settings import RIPPLING_ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.rippling.settings import (+ PAGE_SIZE,+ RIPPLING_ENDPOINTS,+ RipplingEndpointConfig,+)RIPPLING_BASE_URL = "https://rest.ripplingapis.com"RIPPLING_HOST = urlsplit(RIPPLING_BASE_URL).netloc-# Rippling list pages cap at 100 items.-PAGE_SIZE = 100+@frozenclass RipplingResumeConfig:# Rippling cursor pagination returns a `next_link` URL (sometimes relative);# we persist it absolutized, so it's all we need to pick back up.- next_url: str+ next_url: str | None = None+ # Fan-out endpoints checkpoint the framework's per-parent state instead.+ fanout_state: dict[str, Any] | None = Nonedef _format_filter_timestamp(value: Any) -> str:@@ -42,22 +51,23 @@ def _format_filter_timestamp(value: Any) -> str:def _build_params(+ config: RipplingEndpointConfig,should_use_incremental_field: bool,db_incremental_field_last_value: Any,incremental_field: str | None,) -> dict[str, Any]:params: dict[str, Any] = {"limit": PAGE_SIZE}- if should_use_incremental_field and db_incremental_field_last_value is not None:- cursor_field = incremental_field or "updated_at"+ if should_use_incremental_field and config.incremental_fields and db_incremental_field_last_value is not None:+ cursor_field = incremental_field or config.default_incremental_fieldparams["filter"] = f"{cursor_field} ge {_format_filter_timestamp(db_incremental_field_last_value)}"# Ascending order on the cursor field so the incremental watermark# advances monotonically as pages are consumed (order_by defaults to asc).params["order_by"] = cursor_field- else:+ elif config.order_by:# Full refresh: a stable creation-time sort prevents page-boundary# skips/duplicates if rows change mid-sync.- params["order_by"] = "created_at"+ params["order_by"] = config.order_byreturn params@@ -125,54 +135,83 @@ def rippling_source() -> SourceResponse:config = RIPPLING_ENDPOINTS[endpoint]- rest_config: RESTAPIConfig = {- "client": {- "base_url": RIPPLING_BASE_URL,- # Auth (Bearer) via the framework config so the token is redacted from logs/errors.- "auth": {"type": "bearer", "token": api_token},- "paginator": RipplingNextLinkPaginator(),- },- "resource_defaults": {},- "resources": [- {- "name": endpoint,- "endpoint": {- "path": config.path,- "params": _build_params(- should_use_incremental_field, db_incremental_field_last_value, incremental_field- ),- # A missing `results` key is a legit empty page (not a fail-loud shape change).- "data_selector": "results",- },- }- ],+ client_config: ClientConfig = {+ "base_url": RIPPLING_BASE_URL,+ # Auth (Bearer) via the framework config so the token is redacted from logs/errors.+ "auth": {"type": "bearer", "token": api_token},+ "paginator": RipplingNextLinkPaginator(),+ # Pin every request (fan-out child paths included) to the base host so a hostile+ # run id or link can't replay the bearer token elsewhere. `[]` means base_url's host only.+ "allowed_hosts": [],}- initial_paginator_state: Optional[dict[str, Any]] = None- if resumable_source_manager.can_resume():- resume = resumable_source_manager.load_state()- if resume is not None:- initial_paginator_state = {"next_url": resume.next_url}-- def save_checkpoint(state: Optional[dict[str, Any]]) -> None:- # Persist only when a next page remains; save AFTER a page is yielded so a crash re-yields- # the last page (merge dedupes on primary key) rather than skipping it.- if state and state.get("next_url"):- resumable_source_manager.save_state(RipplingResumeConfig(next_url=state["next_url"]))-- resource = rest_api_resource(- rest_config,- team_id,- job_id,- None,- resume_hook=save_checkpoint,- initial_paginator_state=initial_paginator_state,- )+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None++ resource: Any+ if config.fanout is not None:+ initial_fanout_state = resume.fanout_state if resume is not None else None++ def save_fanout_checkpoint(state: Optional[dict[str, Any]]) -> None:+ if state:+ resumable_source_manager.save_state(RipplingResumeConfig(fanout_state=state))++ resource = build_dependent_resource(+ endpoint_configs=RIPPLING_ENDPOINTS,+ child_endpoint=endpoint,+ fanout=config.fanout,+ client_config=client_config,+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ db_incremental_field_last_value=None,+ # A missing `results` key is a legit empty page (not a fail-loud shape change).+ parent_endpoint_extra={"data_selector": "results"},+ child_endpoint_extra={"data_selector": "results"},+ resume_hook=save_fanout_checkpoint,+ initial_paginator_state=initial_fanout_state,+ )+ else:+ rest_config: RESTAPIConfig = {+ "client": client_config,+ "resource_defaults": {},+ "resources": [+ {+ "name": endpoint,+ "endpoint": {+ "path": config.path,+ "params": _build_params(+ config, should_use_incremental_field, db_incremental_field_last_value, incremental_field+ ),+ # A missing `results` key is a legit empty page (not a fail-loud shape change).+ "data_selector": "results",+ },+ }+ ],+ }++ initial_paginator_state = (+ {"next_url": resume.next_url} if resume is not None and resume.next_url is not None else None+ )++ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:+ # Persist only when a next page remains; save AFTER a page is yielded so a crash re-yields+ # the last page (merge dedupes on primary key) rather than skipping it.+ if state and state.get("next_url"):+ resumable_source_manager.save_state(RipplingResumeConfig(next_url=state["next_url"]))++ resource = rest_api_resource(+ rest_config,+ team_id,+ job_id,+ None,+ resume_hook=save_checkpoint,+ initial_paginator_state=initial_paginator_state,+ )return SourceResponse(name=endpoint,items=lambda: resource,- primary_keys=[config.primary_key],+ primary_keys=config.primary_keys,partition_count=1,partition_size=1,partition_mode="datetime" if config.partition_key else None,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/settings.pyindex ab150bbd4d77..65d32b592b6b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/settings.py@@ -1,18 +1,28 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom typing import Optional+from posthog.dataclasses import frozen++from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType+# Rippling list pages cap at 100 items.+PAGE_SIZE = 100+# Every Rippling REST list endpoint supports the same standard query params# (cursor/limit pagination, OData-style `filter`, `order_by` on id/created_at/# updated_at), so the incremental menu is shared.+_UPDATED_AT_INCREMENTAL_FIELD: IncrementalField = {+ "label": "updated_at",+ "type": IncrementalFieldType.DateTime,+ "field": "updated_at",+ "field_type": IncrementalFieldType.DateTime,+}+_STANDARD_INCREMENTAL_FIELDS: list[IncrementalField] = [- {- "label": "updated_at",- "type": IncrementalFieldType.DateTime,- "field": "updated_at",- "field_type": IncrementalFieldType.DateTime,- },+ _UPDATED_AT_INCREMENTAL_FIELD,{"label": "created_at","type": IncrementalFieldType.DateTime,@@ -22,15 +32,24 @@ _STANDARD_INCREMENTAL_FIELDS: list[IncrementalField] = []-@dataclass+@frozenclass RipplingEndpointConfig:name: strpath: str- primary_key: str = "id"+ primary_keys: list[str] = field(default_factory=lambda: ["id"])incremental_fields: list[IncrementalField] = field(default_factory=lambda: list(_STANDARD_INCREMENTAL_FIELDS))# Stable creation-time field used for datetime partitioning. Never an# updated_at-style field, which would rewrite partitions on every sync.partition_key: Optional[str] = None+ # Full-refresh sort field. Must be one of the endpoint's documented sortable fields; None for+ # endpoints that accept no `order_by`.+ order_by: Optional[str] = "created_at"+ fanout: Optional[DependentEndpointConfig] = None+ page_size: int = PAGE_SIZE++ @property+ def default_incremental_field(self) -> Optional[str]:+ return self.incremental_fields[0]["field"] if self.incremental_fields else NoneRIPPLING_ENDPOINTS: dict[str, RipplingEndpointConfig] = {@@ -73,6 +92,42 @@ RIPPLING_ENDPOINTS: dict[str, RipplingEndpointConfig] = {path="/compensations",partition_key="created_at",),+ # Time entries filter on updated_at but not on created_at.+ "time_entries": RipplingEndpointConfig(+ name="time_entries",+ path="/time-entries",+ incremental_fields=[_UPDATED_AT_INCREMENTAL_FIELD],+ partition_key="created_at",+ ),+ # Leave requests filter on neither created_at nor updated_at, so full refresh only.+ "leave_requests": RipplingEndpointConfig(+ name="leave_requests",+ path="/leave-requests",+ incremental_fields=[],+ partition_key="created_at",+ ),+ # Payroll runs carry no created_at/updated_at, accept no filter, and sort only on check_date.+ "payroll_runs": RipplingEndpointConfig(+ name="payroll_runs",+ path="/payroll-runs",+ incremental_fields=[],+ order_by="check_date",+ ),+ "worker_payroll_records": RipplingEndpointConfig(+ name="worker_payroll_records",+ path="/payroll-runs/{run_id}/worker-payroll-records",+ primary_keys=["run_id", "id"],+ incremental_fields=[],+ order_by=None,+ fanout=DependentEndpointConfig(+ parent_name="payroll_runs",+ resolve_param="run_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "run_id"},+ parent_params={"order_by": "check_date"},+ ),+ ),}ENDPOINTS = tuple(RIPPLING_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/source.pyindex d9ce9097b5f6..f2d1dcaadd6d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/source.py@@ -75,7 +75,7 @@ class RipplingSource(ResumableSource[RipplingSourceConfig, RipplingResumeConfig]label="Rippling",caption="""Enter your Rippling API token to pull your Rippling workforce data into the PostHog Data warehouse.-A Rippling admin can create a scoped API token under Settings > Company Settings > API Access. Enable the read scope for each dataset you want to sync (e.g. `companies.read`, `users.read`, `workers.read`, `departments.read`, `teams.read`, `levels.read`, `work-locations.read`, `employment-types.read`, `compensations.read`). Note that tokens expire after 30 days of inactivity.""",+A Rippling admin can create a scoped API token under Settings > Company Settings > API Access. Enable the read scope for each dataset you want to sync (e.g. `companies.read`, `users.read`, `workers.read`, `departments.read`, `teams.read`, `levels.read`, `work-locations.read`, `employment-types.read`, `compensations.read`, `time-entries.read`, `leave-requests.read`, `payroll-runs.read`, `worker-payroll-records.read`). Payroll tables need Rippling Global Payroll. Note that tokens expire after 30 days of inactivity.""",iconPath="/static/services/rippling.png",docsUrl="https://posthog.com/docs/cdp/sources/rippling",releaseStatus=ReleaseStatus.ALPHA,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/tests/test_rippling.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/tests/test_rippling.pyindex 3d312f943015..e831415edbbc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/tests/test_rippling.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rippling/tests/test_rippling.py@@ -7,6 +7,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.tesScriptedResponse,SourceDriver,always,+ route,scripted_network,)from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.rippling import (@@ -20,6 +21,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.rippling.r_format_filter_timestamp,validate_credentials,)+from products.warehouse_sources.backend.temporal.data_imports.sources.rippling.settings import RIPPLING_ENDPOINTSfrom products.warehouse_sources.backend.temporal.data_imports.sources.rippling.source import RipplingSource@@ -46,15 +48,32 @@ class TestFormatFilterTimestamp:class TestBuildParams:- def test_incremental_builds_odata_filter_and_sort(self):+ @pytest.mark.parametrize(+ "endpoint, should_use_incremental_field, incremental_field, expected_filter, expected_order_by",+ [+ ("workers", True, "updated_at", "updated_at ge 2024-10-01T00:00:00", "updated_at"),+ ("workers", True, "created_at", "created_at ge 2024-10-01T00:00:00", "created_at"),+ ("workers", False, None, None, "created_at"),+ ("time_entries", True, None, "updated_at ge 2024-10-01T00:00:00", "updated_at"),+ ("time_entries", False, None, None, "created_at"),+ # No server-side time filter exists, so a stray incremental flag must not send one.+ ("leave_requests", True, "updated_at", None, "created_at"),+ ("payroll_runs", True, None, None, "check_date"),+ ("payroll_runs", False, None, None, "check_date"),+ ],+ )+ def test_request_params(+ self, endpoint, should_use_incremental_field, incremental_field, expected_filter, expected_order_by+ ):params = _build_params(- should_use_incremental_field=True,+ RIPPLING_ENDPOINTS[endpoint],+ should_use_incremental_field=should_use_incremental_field,db_incremental_field_last_value=datetime(2024, 10, 1, tzinfo=UTC),- incremental_field="updated_at",+ incremental_field=incremental_field,)- assert params["filter"] == "updated_at ge 2024-10-01T00:00:00"- assert params["order_by"] == "updated_at"+ assert params.get("filter") == expected_filter+ assert params["order_by"] == expected_order_byassert params["limit"] == PAGE_SIZE@@ -111,3 +130,62 @@ class TestGetRows:assert isinstance(result.raised, ValueError)assert "off-domain" in str(result.raised)+++class TestWorkerPayrollRecordsFanout:+ def test_walks_every_run_and_page_and_stamps_run_id(self):+ script = route(+ {+ "/payroll-runs": [+ _response([{"id": "run-1"}], next_link="/payroll-runs?cursor=p2"),+ _response([{"id": "run-2"}]),+ ],+ "/payroll-runs/run-1/worker-payroll-records": [+ _response(+ [{"id": "rec-1", "worker_id": "w-1"}],+ next_link="/payroll-runs/run-1/worker-payroll-records?cursor=c2",+ ),+ _response([{"id": "rec-2", "worker_id": "w-2", "run_id": "run-1"}]),+ ],+ "/payroll-runs/run-2/worker-payroll-records": [+ _response([{"id": "rec-1", "worker_id": "w-1"}]),+ ],+ }+ )++ result = _driver().run("worker_payroll_records", script)++ assert result.raised is None+ assert [(row["run_id"], row["id"]) for row in result.rows] == [+ ("run-1", "rec-1"),+ ("run-1", "rec-2"),+ ("run-2", "rec-1"),+ ]+ assert not any("_payroll_runs_id" in row for row in result.rows)+ parent_queries = [q for q, path in zip(result.queries, result.paths) if path == "/payroll-runs"]+ child_queries = [q for q, path in zip(result.queries, result.paths) if path != "/payroll-runs"]+ assert parent_queries[0]["order_by"] == ("check_date",)+ assert all("order_by" not in q for q in child_queries)++ def test_resume_skips_completed_runs_and_continues_the_current_one(self):+ resume = RipplingResumeConfig(+ fanout_state={+ "completed": ["/payroll-runs/run-1/worker-payroll-records"],+ "current": "/payroll-runs/run-2/worker-payroll-records",+ "child_state": {+ "next_url": "https://rest.ripplingapis.com/payroll-runs/run-2/worker-payroll-records?cursor=c9"+ },+ }+ )+ script = route(+ {+ "/payroll-runs": [_response([{"id": "run-1"}, {"id": "run-2"}])],+ "/payroll-runs/run-2/worker-payroll-records": [_response([{"id": "rec-9", "worker_id": "w-9"}])],+ }+ )++ result = _driver().run("worker_payroll_records", script, resume_state=resume)++ assert result.raised is None+ assert [row["id"] for row in result.rows] == ["rec-9"]+ assert result.urls[-1] == "https://rest.ripplingapis.com/payroll-runs/run-2/worker-payroll-records?cursor=c9"