Skip to content

: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.

feat(warehouse-sources): sync ashby feedback, history, stages and events (#99675)

Tom Owersbd732cecbe4b
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.md
index c2ad13ca0778..b01a6b57ed79 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
@@ -524,16 +524,16 @@ Note: Diffed against Asana's official OpenAPI spec (3 MB, ~120 GET paths). Also
## Ashby — gaps
-Today (18): `applications`, `archive_reasons`, `candidate_tags`, `candidates`, `custom_fields`, `departments`, `interview_schedules`, `interviews`, `job_postings`, `jobs`, `locations`, `offers`, `openings`, `projects`, `referrals`, `sequences`, `sources`, `users`
+Today (22): `application_feedback`, `application_history`, `applications`, `archive_reasons`, `candidate_tags`, `candidates`, `custom_fields`, `departments`, `interview_events`, `interview_schedules`, `interview_stages`, `interviews`, `job_postings`, `jobs`, `locations`, `offers`, `openings`, `projects`, `referrals`, `sequences`, `sources`, `users`
Diffed against: <https://developers.ashbyhq.com/reference/introduction>
- [x] `referral.list` — candidate referrals tying a referrer to an application/job, a sourcing-attribution table (medium)
- [x] `sequence.list` — candidate enrollments in outreach sequences, with per-stage scheduling (medium)
-- [ ] `applicationFeedback.list` — interview scorecards and ratings, the core quality signal for hiring analytics (high)
-- [ ] `application.listHistory` — stage-transition history; without it you cannot compute time-in-stage or funnel conversion (high)
-- [ ] `interviewStage.list` — lookup resolving the currentInterviewStage ID carried on every synced application (high)
-- [ ] `interviewEvent.list` — actual scheduled interview occurrences with interviewers and times, distinct from the interview definitions we sync (high)
+- [x] `applicationFeedback.list` — interview scorecards and ratings, the core quality signal for hiring analytics (high)
+- [x] `application.listHistory` — stage-transition history; without it you cannot compute time-in-stage or funnel conversion (high)
+- [x] `interviewStage.list` — lookup resolving the currentInterviewStage ID carried on every synced application (high)
+- [x] `interviewEvent.list` — actual scheduled interview occurrences with interviewers and times, distinct from the interview definitions we sync (high)
- [ ] `interviewStageGroup.list` — lookup grouping stages into funnel phases for stage-level reporting (medium)
- [ ] `applicationHiringTeamRole.list` — membership table linking users to applications by role (recruiter, hiring manager) (medium)
- [ ] `surveySubmission.list` — candidate survey responses (including DEI surveys) tied to applications (medium)
@@ -543,6 +543,8 @@ Diffed against: <https://developers.ashbyhq.com/reference/introduction>
- [ ] `takeHomeAssignment.list` — assignment issue/completion records, a stage most funnels drop out at (medium)
- [ ] `sourceTrackingLink.list` — resolves attribution links behind the sources table already synced (low)
+Note: `interview_events` is served from the nested `interviewEvents` array that `interviewSchedule.list` already returns in full, rather than fanning `interviewEvent.list` out once per schedule — both carry the same `InterviewEvent` objects.
+
Note: Ashby's readme.io OpenAPI JSON is not publicly downloadable (404), so the resource list was read from the full reference navigation on the introduction page, filtering on \*.list endpoints. Other list endpoints deliberately excluded as config: communicationTemplate, emailSender, sequenceTemplate, jobBoard, jobTemplate, brand, apiKey, webhook.
Excluded as not table-shaped: `notetakerTranscript.info` is a single-object getter keyed by a `notetakerTranscriptId` (not enumerable, and it returns a transient pre-signed download URL); `candidate.getRecentEmailMessages` is a per-candidate fetch with no durable row id (`recordId` is documented as non-durable) and a silent 200-message snapshot cap, so it does not map to a stable, complete table.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/ashby.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/ashby.py
index 25262e4e16ca..fcb4a1f08c48 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/ashby.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/ashby.py
@@ -1,9 +1,14 @@
import dataclasses
+from collections.abc import Callable, Iterator
from typing import Any, Optional
from requests import Response
-from products.warehouse_sources.backend.temporal.data_imports.sources.ashby.settings import ASHBY_ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.ashby.settings import (
+ ASHBY_ENDPOINTS,
+ PAGE_SIZE,
+ AshbyEndpointConfig,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
RESTAPIConfig,
@@ -16,7 +21,6 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
ASHBY_BASE_URL = "https://api.ashbyhq.com"
-PAGE_SIZE = 100 # Ashby's documented max (and default).
# Cheap endpoint to confirm a key is genuine when no specific schema is being validated.
DEFAULT_PROBE_PATH = "department.list"
@@ -27,9 +31,16 @@ class AshbyAPIError(Exception):
pass
[email protected](frozen=True)
class AshbyResumeConfig:
- cursor: str
+ cursor: Optional[str] = None
+ """Next page cursor for a directly listed endpoint."""
+ parent_cursor: Optional[str] = None
+ """Fan-out: the cursor that fetched the parent page being walked."""
+ parent_index: int = 0
+ """Fan-out: how many parents in that page are already finished."""
+ child_cursor: Optional[str] = None
+ """Fan-out: next page cursor for the parent currently in progress."""
def _headers() -> dict[str, str]:
@@ -86,62 +97,175 @@ class AshbyCursorPaginator(JSONResponseCursorPaginator):
self._has_next_page = False
-def ashby_source(
- api_key: str,
- endpoint: str,
- team_id: int,
- job_id: str,
- resumable_source_manager: ResumableSourceManager[AshbyResumeConfig],
-) -> SourceResponse:
- config = ASHBY_ENDPOINTS[endpoint]
-
- rest_config: RESTAPIConfig = {
+def _rest_config(api_key: str, name: str, path: str, body: dict[str, Any]) -> RESTAPIConfig:
+ return {
"client": {
"base_url": ASHBY_BASE_URL,
"headers": _headers(),
# Ashby uses HTTP Basic auth: API key as username, empty password.
"auth": {"type": "http_basic", "username": api_key, "password": ""},
- "paginator": AshbyCursorPaginator(config.path),
+ "paginator": AshbyCursorPaginator(path),
},
"resource_defaults": {},
"resources": [
{
- "name": endpoint,
+ "name": name,
"endpoint": {
- "path": config.path,
+ "path": path,
"method": "post",
- "json": {"limit": PAGE_SIZE},
+ "json": body,
"data_selector": "results",
},
}
],
}
- 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 = {"cursor": resume.cursor}
- def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
- # Persist only when a next page remains; the checkpoint fires AFTER a page is yielded so a
- # crash re-fetches from the next page (already-yielded pages are persisted); merge/replace
- # dedupes on the primary key.
- if state and state.get("cursor"):
- resumable_source_manager.save_state(AshbyResumeConfig(cursor=str(state["cursor"])))
+def _iter_pages(
+ api_key: str,
+ name: str,
+ path: str,
+ body: dict[str, Any],
+ team_id: int,
+ job_id: str,
+ *,
+ start_cursor: Optional[str] = None,
+ on_next_cursor: Optional[Callable[[Optional[str]], None]] = None,
+) -> Iterator[tuple[list[dict[str, Any]], Optional[str]]]:
+ """Yield each page of an Ashby list method with the cursor that fetched it.
+
+ ``on_next_cursor`` receives the cursor for the page after the one just yielded, or ``None``
+ once the listing is exhausted.
+ """
+ next_cursor: dict[str, Optional[str]] = {"value": None}
+
+ def remember(state: Optional[dict[str, Any]]) -> None:
+ next_cursor["value"] = str(state["cursor"]) if state and state.get("cursor") else None
+ if on_next_cursor is not None:
+ on_next_cursor(next_cursor["value"])
resource = rest_api_resource(
- rest_config,
+ _rest_config(api_key, name, path, body),
team_id,
job_id,
None, # every Ashby endpoint is full refresh
- resume_hook=save_checkpoint,
- initial_paginator_state=initial_paginator_state,
+ resume_hook=remember,
+ initial_paginator_state={"cursor": start_cursor} if start_cursor else None,
)
+ cursor = start_cursor
+ for index, page in enumerate(resource):
+ if index:
+ # ``remember`` for the previous page runs as the resource advances above, so by now
+ # it holds the cursor that fetched the page we are about to yield.
+ cursor = next_cursor["value"]
+ yield page, cursor
+
+
+def _listed_pages(
+ api_key: str,
+ config: AshbyEndpointConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[AshbyResumeConfig],
+) -> Iterator[list[dict[str, Any]]]:
+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+
+ def save_checkpoint(cursor: Optional[str]) -> None:
+ # Persist only when a next page remains; the checkpoint fires AFTER a page is yielded so a
+ # crash re-fetches from the next page (already-yielded pages are persisted); merge/replace
+ # dedupes on the primary key.
+ if cursor:
+ resumable_source_manager.save_state(AshbyResumeConfig(cursor=cursor))
+
+ body: dict[str, Any] = {} if config.page_size is None else {"limit": config.page_size}
+ for page, _ in _iter_pages(
+ api_key,
+ config.name,
+ config.path,
+ body,
+ team_id,
+ job_id,
+ start_cursor=resume.cursor if resume else None,
+ on_next_cursor=save_checkpoint,
+ ):
+ yield [row for item in page for row in (item.get(config.nested_field) or [])] if config.nested_field else page
+
+
+def _fanned_out_pages(
+ api_key: str,
+ config: AshbyEndpointConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[AshbyResumeConfig],
+) -> Iterator[list[dict[str, Any]]]:
+ fanout = config.fanout
+ assert fanout is not None
+
+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+ child_cursor = resume.child_cursor if resume else None
+ skip = resume.parent_index if resume else 0
+
+ for parent_page, parent_cursor in _iter_pages(
+ api_key,
+ fanout.parent_path,
+ fanout.parent_path,
+ {"limit": PAGE_SIZE},
+ team_id,
+ job_id,
+ start_cursor=resume.parent_cursor if resume else None,
+ ):
+ for index, parent in enumerate(parent_page):
+ if index < skip:
+ continue
+
+ parent_id = parent["id"]
+ body: dict[str, Any] = {fanout.resolve_param: parent_id}
+ if config.page_size is not None:
+ body["limit"] = config.page_size
+
+ def save_child_checkpoint(
+ cursor: Optional[str], page: Optional[str] = parent_cursor, at: int = index
+ ) -> None:
+ if cursor:
+ resumable_source_manager.save_state(
+ AshbyResumeConfig(parent_cursor=page, parent_index=at, child_cursor=cursor)
+ )
+
+ for child_page, _ in _iter_pages(
+ api_key,
+ config.name,
+ config.path,
+ body,
+ team_id,
+ job_id,
+ start_cursor=child_cursor,
+ on_next_cursor=save_child_checkpoint,
+ ):
+ if fanout.parent_id_field:
+ for row in child_page:
+ row.setdefault(fanout.parent_id_field, parent_id)
+ yield child_page
+
+ child_cursor = None
+ resumable_source_manager.save_state(AshbyResumeConfig(parent_cursor=parent_cursor, parent_index=index + 1))
+
+ skip = 0
+
+
+def ashby_source(
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[AshbyResumeConfig],
+) -> SourceResponse:
+ config = ASHBY_ENDPOINTS[endpoint]
+ pages = _fanned_out_pages if config.fanout else _listed_pages
+
return SourceResponse(
name=endpoint,
- items=lambda: resource,
+ items=lambda: pages(api_key, config, team_id, job_id, resumable_source_manager),
primary_keys=config.primary_key,
partition_count=1,
partition_size=1,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/canonical_descriptions.py
index 25e22c171038..623579f3bc17 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/canonical_descriptions.py
@@ -218,4 +218,67 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"stages": "The sequence's stages and their scheduling details.",
},
},
+ "application_feedback": {
+ "description": "An interview scorecard submitted against an application in Ashby.",
+ "docs_url": "https://developers.ashbyhq.com/reference/applicationfeedbacklist",
+ "columns": {
+ "id": _COMMON_COLUMNS["id"],
+ "applicationId": "ID of the application the feedback was submitted for.",
+ "feedbackFormDefinitionId": "ID of the feedback form definition used, if any.",
+ "formDefinition": "The feedback form's sections and fields.",
+ "submittedValues": "The submitted answers, keyed by the matching form field path. Selections come back as the stored option value, not its display label.",
+ "submittedByUser": "The user who submitted the feedback.",
+ "creditedToUser": "The user the feedback is attributed to. For interview feedback this is the interviewer whose assignment it was submitted for.",
+ "interviewId": "ID of the interview the feedback relates to, if any.",
+ "interviewEventId": "ID of the interview event the feedback relates to, if any.",
+ "applicationHistoryId": "ID of the application history entry the feedback relates to, if any.",
+ "submittedAt": "Time at which the feedback was submitted.",
+ },
+ },
+ "application_history": {
+ "description": "One stage an application passed through, with when it entered and left. The rows for an application reconstruct its funnel.",
+ "docs_url": "https://developers.ashbyhq.com/reference/applicationlisthistory",
+ "columns": {
+ "id": "Unique identifier for the history event.",
+ "applicationId": "ID of the application this history event belongs to.",
+ "stageId": "ID of the interview stage for this event.",
+ "title": "The interview stage title for this event.",
+ "enteredStageAt": "Time at which the application entered this stage.",
+ "leftStageAt": "Time at which the application left this stage, if it has.",
+ "stageNumber": "Order of this event in the application's history. 0 is the first event.",
+ "allowedActions": "Actions that can be performed on this history event through the Ashby API.",
+ "actorId": "ID of the user who performed the stage change, if any.",
+ },
+ },
+ "interview_stages": {
+ "description": "A stage in an Ashby interview plan. Resolves the stage IDs carried on applications and interview schedules.",
+ "docs_url": "https://developers.ashbyhq.com/reference/interviewstagelist",
+ "columns": {
+ "id": _COMMON_COLUMNS["id"],
+ "title": "The stage's title.",
+ "type": "Type of the stage (PreInterviewScreen, Active, Offer, Hired, Archived).",
+ "interviewPlanId": "ID of the interview plan the stage belongs to.",
+ "orderInInterviewPlan": "Position of the stage within its interview plan.",
+ "interviewStageGroupId": "ID of the stage group this stage belongs to, if any.",
+ },
+ },
+ "interview_events": {
+ "description": "A scheduled occurrence of an interview, with its interviewers and times.",
+ "docs_url": "https://developers.ashbyhq.com/reference/intervieweventlist",
+ "columns": _columns(
+ interviewId="ID of the interview being run.",
+ interviewScheduleId="ID of the interview schedule this event belongs to.",
+ interviewerUserIds="IDs of the users interviewing. Deprecated by Ashby in favour of interviewers.",
+ interviewers="The users interviewing, with their training role, interviewer pool and whether feedback is required.",
+ startTime="Time at which the event starts.",
+ endTime="Time at which the event ends.",
+ feedbackLink="Link for submitting feedback on the event.",
+ location="Where the interview takes place, if set.",
+ meetingLink="Link to the video meeting, if set.",
+ interviewerCalendarEventId="ID of the matching event on the interviewer's calendar, if set.",
+ hasSubmittedFeedback="Whether any feedback has been submitted for this event.",
+ notetakerTranscriptId="ID of the notetaker transcript for this event, if any.",
+ extraData="Arbitrary key/value pairs stored against the event.",
+ ),
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/settings.py
index f882d18f4959..ca063f419a99 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/settings.py
@@ -1,8 +1,20 @@
from dataclasses import dataclass
from typing import Optional
+PAGE_SIZE = 100 # Ashby's documented max (and default).
-@dataclass
+
+@dataclass(frozen=True)
+class AshbyFanoutConfig:
+ parent_path: str
+ """Ashby list method walked to enumerate parents. Not necessarily a table we expose."""
+ resolve_param: str
+ """Request-body key on the child method that takes the parent's ``id``."""
+ parent_id_field: Optional[str] = None
+ """Field the parent's ``id`` is written onto, for children that don't already carry it."""
+
+
+@dataclass(frozen=True)
class AshbyEndpointConfig:
name: str
"""Table name we expose to the user (snake_case)."""
@@ -12,9 +24,25 @@ class AshbyEndpointConfig:
partition_key: Optional[str] = None
"""A STABLE creation-time field to partition on. ``None`` disables partitioning.
- Only set where the object is documented to carry a top-level ``createdAt`` — never a
- mutable field like ``updatedAt`` (partitions would rewrite on every sync).
+ Only set where the object is documented to carry a top-level creation timestamp that Ashby
+ never rewrites — never a mutable field like ``updatedAt`` (partitions would rewrite on
+ every sync).
"""
+ page_size: Optional[int] = PAGE_SIZE
+ """``None`` for methods that accept no ``limit`` — Ashby rejects unknown request-body keys."""
+ nested_field: Optional[str] = None
+ """Rows come from this array on each item of ``path``, instead of from the items themselves."""
+ fanout: Optional[AshbyFanoutConfig] = None
+ """Set when ``path`` must be called once per parent row rather than listed directly."""
+
+ @property
+ def probe_path(self) -> str:
+ """Path to probe when validating access to this table.
+
+ A fan-out child can't be called without a parent id, so we probe the parent listing the
+ sync starts from; both sit behind the same Ashby permission.
+ """
+ return self.fanout.parent_path if self.fanout else self.path
# Every Ashby object exposes a top-level ``id``, so the primary key is ``["id"]`` throughout.
@@ -53,6 +81,37 @@ ASHBY_ENDPOINTS: dict[str, AshbyEndpointConfig] = {
"sequences": AshbyEndpointConfig(
name="sequences", path="sequence.list", primary_key=["id"], partition_key="createdAt"
),
+ "application_feedback": AshbyEndpointConfig(
+ name="application_feedback",
+ path="applicationFeedback.list",
+ primary_key=["id"],
+ partition_key="submittedAt",
+ ),
+ "application_history": AshbyEndpointConfig(
+ name="application_history",
+ path="application.listHistory",
+ primary_key=["applicationId", "id"],
+ # enteredStageAt is editable through application.updateHistory, so it can't partition.
+ fanout=AshbyFanoutConfig(
+ parent_path="application.list", resolve_param="applicationId", parent_id_field="applicationId"
+ ),
+ ),
+ "interview_stages": AshbyEndpointConfig(
+ name="interview_stages",
+ path="interviewStage.list",
+ primary_key=["interviewPlanId", "id"],
+ page_size=None,
+ fanout=AshbyFanoutConfig(parent_path="interviewPlan.list", resolve_param="interviewPlanId"),
+ ),
+ "interview_events": AshbyEndpointConfig(
+ name="interview_events",
+ path="interviewSchedule.list",
+ primary_key=["id"],
+ partition_key="createdAt",
+ # interviewSchedule.list already returns every event in full, so read them from there
+ # instead of calling interviewEvent.list once per schedule.
+ nested_field="interviewEvents",
+ ),
}
ENDPOINTS = tuple(ASHBY_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/source.py
index 087be9f8d25c..62c8f4cb0daa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/source.py
@@ -98,7 +98,7 @@ You can create an API key under **Admin → API Keys** in Ashby. Grant read perm
if schema_name is not None and schema_name not in ASHBY_ENDPOINTS:
return False, f"Unknown Ashby schema '{schema_name}'"
- path = ASHBY_ENDPOINTS[schema_name].path if schema_name is not None else DEFAULT_PROBE_PATH
+ path = ASHBY_ENDPOINTS[schema_name].probe_path if schema_name is not None else DEFAULT_PROBE_PATH
status, message = check_access(config.api_key, path)
if status == 200:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby.py
index 580f9f062712..9a2107182ba0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby.py
@@ -308,4 +308,115 @@ class TestAshbySourceResponse:
def test_all_endpoints_buildable(self, MockSession) -> None:
for endpoint in ENDPOINTS:
response = _source(endpoint)
- assert response.primary_keys == ["id"]
+ # A table with no primary key can never merge or dedupe a re-yielded page.
+ assert response.primary_keys
+
+
+class TestFanOut:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_calls_the_child_once_per_parent_and_injects_the_parent_id(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _page([{"id": "app-1"}, {"id": "app-2"}], more=False),
+ _page([{"id": "h-1", "stageNumber": 0}], more=False),
+ _page([{"id": "h-2", "stageNumber": 0}], more=False),
+ ],
+ )
+
+ rows = _rows(_source("application_history"))
+
+ # application.listHistory rows carry no applicationId, so the fan-out has to add it —
+ # without it the table can't be joined back to applications and its key isn't unique.
+ assert rows == [
+ {"id": "h-1", "stageNumber": 0, "applicationId": "app-1"},
+ {"id": "h-2", "stageNumber": 0, "applicationId": "app-2"},
+ ]
+ assert [snapshot["url"] for snapshot in snapshots] == [
+ f"{ASHBY_BASE_URL}/application.list",
+ f"{ASHBY_BASE_URL}/application.listHistory",
+ f"{ASHBY_BASE_URL}/application.listHistory",
+ ]
+ assert snapshots[1]["json"] == {"applicationId": "app-1", "limit": 100}
+ assert snapshots[2]["json"] == {"applicationId": "app-2", "limit": 100}
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_unpaginated_child_sends_only_the_resolve_param(self, MockSession) -> None:
+ # interviewStage.list takes interviewPlanId and nothing else — Ashby rejects a `limit`.
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _page([{"id": "plan-1"}], more=False),
+ _page([{"id": "stage-1", "interviewPlanId": "plan-1"}], more=False),
+ ],
+ )
+
+ rows = _rows(_source("interview_stages"))
+
+ assert rows == [{"id": "stage-1", "interviewPlanId": "plan-1"}]
+ assert snapshots[1]["json"] == {"interviewPlanId": "plan-1"}
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_resumes_at_the_parent_that_was_in_progress(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _page([{"id": "app-1"}, {"id": "app-2"}], more=False),
+ _page([{"id": "h-2"}], more=False),
+ ],
+ )
+ manager = _make_manager(AshbyResumeConfig(parent_index=1, child_cursor="half-way"))
+
+ rows = _rows(_source("application_history", manager))
+
+ assert rows == [{"id": "h-2", "applicationId": "app-2"}]
+ assert snapshots[1]["json"]["cursor"] == "half-way"
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_checkpoints_each_finished_parent_against_its_page_cursor(self, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ _page([{"id": "app-1"}], more=True, next_cursor="p2"),
+ _page([{"id": "h-1"}], more=False),
+ _page([{"id": "app-2"}], more=False),
+ _page([{"id": "h-2"}], more=False),
+ ],
+ )
+ manager = _make_manager()
+
+ _rows(_source("application_history", manager))
+
+ # The second parent is recorded against "p2" — the cursor that fetched the page it is on,
+ # not the one that fetched the page before it.
+ assert manager.save_state.call_args_list == [
+ mock.call(AshbyResumeConfig(parent_cursor=None, parent_index=1)),
+ mock.call(AshbyResumeConfig(parent_cursor="p2", parent_index=1)),
+ ]
+
+
+class TestNestedRows:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_interview_events_are_read_from_the_schedule_listing(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _page(
+ [
+ {"id": "sched-1", "interviewEvents": [{"id": "ev-1"}, {"id": "ev-2"}]},
+ {"id": "sched-2", "interviewEvents": []},
+ ],
+ more=False,
+ )
+ ],
+ )
+
+ rows = _rows(_source("interview_events"))
+
+ assert rows == [{"id": "ev-1"}, {"id": "ev-2"}]
+ assert snapshots[0]["url"] == f"{ASHBY_BASE_URL}/interviewSchedule.list"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby_source.py
index 1d4442c942e6..39320350ce70 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ashby/tests/test_ashby_source.py
@@ -64,6 +64,19 @@ class TestAshbySource:
self.source.validate_credentials(self.config, self.team_id, schema_name="candidates")
mock_check.assert_called_once_with("ashby-key", "candidate.list")
+ @pytest.mark.parametrize(
+ "schema_name, expected_path",
+ [("application_history", "application.list"), ("interview_stages", "interviewPlan.list")],
+ )
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.ashby.source.check_access")
+ def test_validate_credentials_probes_the_parent_of_a_fanned_out_schema(
+ self, mock_check: mock.MagicMock, schema_name: str, expected_path: str
+ ) -> None:
+ # The child methods need a parent id, so probing them directly always fails.
+ mock_check.return_value = (200, None)
+ self.source.validate_credentials(self.config, self.team_id, schema_name=schema_name)
+ mock_check.assert_called_once_with("ashby-key", expected_path)
+
@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.ashby.source.check_access")
def test_validate_credentials_uses_default_probe_without_schema(self, mock_check: mock.MagicMock) -> None:
mock_check.return_value = (200, None)