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(data-warehouse): add likes and quotes tables to the bluesky source (#118995)

Tom Owers47a2ac8fcd3e
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 a443bcfd8e67..4b8070eb91ee 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
@@ -1746,16 +1746,16 @@ Note: The OpenAPI file linked from the official REST reference lists all collect
## Bluesky — gaps
-Today (4): `Followers`, `Follows`, `Posts`, `Profile`
+Today (6): `Followers`, `Follows`, `Likes`, `Posts`, `Profile`, `Quotes`
Diffed against: <https://github.com/bluesky-social/atproto/tree/main/lexicons/app/bsky>
-- [ ] `getLikes (GET /xrpc/app.bsky.feed.getLikes)` — identify people who like synced posts for audience attribution and engagement analysis (high)
-- [ ] `searchPosts (GET /xrpc/app.bsky.feed.searchPosts)` — find brand mentions and relevant conversations beyond the selected account posts (high)
+- [x] `getLikes (GET /xrpc/app.bsky.feed.getLikes)` — identify people who like synced posts for audience attribution and engagement analysis (high). Added as `Likes` (fan-out over `Posts`).
+- [ ] `searchPosts (GET /xrpc/app.bsky.feed.searchPosts)` — find brand mentions and relevant conversations beyond the selected account posts (high); skipped, the public AppView this source uses answers it with 403 without an authenticated session, and it needs a search query the source has no field for
- [ ] `getRepostedBy (GET /xrpc/app.bsky.feed.getRepostedBy)` — identify accounts that amplify posts and connect reposts to audience growth (medium)
- [ ] `getPostThread (GET /xrpc/app.bsky.feed.getPostThread)` — analyze replies and conversation structure around synced posts (medium)
-- [ ] `getQuotes (GET /xrpc/app.bsky.feed.getQuotes)` — analyze quoted posts and commentary that aggregate quote counts cannot explain (medium)
-- [ ] `listNotifications (GET /xrpc/app.bsky.notification.listNotifications)` — track engagement notifications with timestamps, including mentions, likes, reposts, and follows (medium)
+- [x] `getQuotes (GET /xrpc/app.bsky.feed.getQuotes)` — analyze quoted posts and commentary that aggregate quote counts cannot explain (medium). Added as `Quotes` (fan-out over `Posts`).
+- [ ] `listNotifications (GET /xrpc/app.bsky.notification.listNotifications)` — track engagement notifications with timestamps, including mentions, likes, reposts, and follows (medium); skipped, it returns the authenticated account's own notifications and needs an account session, while this source only takes a public handle
- [ ] `getLists (GET /xrpc/app.bsky.graph.getLists)` — analyze named audience lists created by the selected account (medium)
- [ ] `getList (GET /xrpc/app.bsky.graph.getList)` — analyze list membership and connections between curated audiences (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/bluesky.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/bluesky.py
index c24d3c0a9e8f..43369ba8ec60 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/bluesky.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/bluesky.py
@@ -1,8 +1,13 @@
+from collections.abc import Iterator
from typing import Any, Optional
from posthog.dataclasses import frozen
-from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.settings import BASE_URL
+from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.settings import (
+ BASE_URL,
+ POST_FANOUT_ENDPOINTS,
+ PostFanoutEndpoint,
+)
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,
@@ -13,13 +18,21 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
SinglePagePaginator,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import RESTClient
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import EndpointResource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
@frozen
class BlueskyResumeConfig:
- cursor: str
+ # Flat listings resume from the next page cursor.
+ cursor: Optional[str] = None
+ # Post fan-out tables resume from a fixed-size position: the cursor of the feed page, the post
+ # on that page to continue from, and that post's next child page. A list of finished posts
+ # would grow with the account's history and be rewritten on every checkpoint.
+ feed_cursor: Optional[str] = None
+ post_uri: Optional[str] = None
+ child_cursor: Optional[str] = None
def _cursor_paginator() -> JSONResponseCursorPaginator:
@@ -28,6 +41,17 @@ def _cursor_paginator() -> JSONResponseCursorPaginator:
return JSONResponseCursorPaginator(cursor_path="cursor", cursor_param="cursor")
+_FEED_PATH = "/xrpc/app.bsky.feed.getAuthorFeed"
+_FEED_DATA_SELECTOR = "feed[*].post"
+
+
+def _feed_params(actor: str) -> dict[str, Any]:
+ # `posts_no_replies` keeps this table to the author's own posts and reposts,
+ # matching what most brand/marketing tracking cares about (own content, not
+ # every reply the account has made).
+ return {"actor": actor, "limit": 100, "filter": "posts_no_replies"}
+
+
def get_resource(name: str, actor: str) -> EndpointResource:
resources: dict[str, EndpointResource] = {
"Profile": {
@@ -48,12 +72,9 @@ def get_resource(name: str, actor: str) -> EndpointResource:
"write_disposition": "replace",
"table_format": "delta",
"endpoint": {
- "path": "/xrpc/app.bsky.feed.getAuthorFeed",
- # `posts_no_replies` keeps this table to the author's own posts and reposts,
- # matching what most brand/marketing tracking cares about (own content, not
- # every reply the account has made).
- "params": {"actor": actor, "limit": 100, "filter": "posts_no_replies"},
- "data_selector": "feed[*].post",
+ "path": _FEED_PATH,
+ "params": _feed_params(actor),
+ "data_selector": _FEED_DATA_SELECTOR,
"paginator": _cursor_paginator(),
},
},
@@ -85,6 +106,101 @@ def get_resource(name: str, actor: str) -> EndpointResource:
return resources[name]
+def _fanout_row(endpoint: str, config: PostFanoutEndpoint, post_uri: str, row: dict[str, Any]) -> dict[str, Any]:
+ row[config.parent_uri_column] = post_uri
+ if endpoint == "Likes":
+ # A like row has no id of its own, so the liker's DID keys it within the post.
+ actor = row.get("actor") or {}
+ row["actor_did"] = actor.get("did")
+ return row
+
+
+def _cursor_from_state(state: Optional[dict[str, Any]]) -> Optional[str]:
+ cursor = (state or {}).get("cursor")
+ return str(cursor) if cursor else None
+
+
+def post_fanout_rows(
+ actor: str,
+ endpoint: str,
+ resumable_source_manager: ResumableSourceManager[BlueskyResumeConfig],
+) -> Iterator[list[dict[str, Any]]]:
+ config = POST_FANOUT_ENDPOINTS[endpoint]
+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+ page_cursor = resume.feed_cursor if resume else None
+ resume_post = resume.post_uri if resume else None
+ resume_child_cursor = resume.child_cursor if resume else None
+ # A repost of the account's own post puts the same post in the feed twice.
+ seen: set[str] = set()
+
+ next_feed: dict[str, Optional[str]] = {}
+ next_child: dict[str, Optional[str]] = {}
+
+ def remember_feed(state: Optional[dict[str, Any]], has_next: bool) -> None:
+ next_feed["cursor"] = _cursor_from_state(state)
+
+ def remember_child(state: Optional[dict[str, Any]], has_next: bool) -> None:
+ next_child["cursor"] = _cursor_from_state(state)
+
+ client = RESTClient(base_url=BASE_URL)
+ try:
+ for posts in client.paginate(
+ path=_FEED_PATH,
+ params=_feed_params(actor),
+ paginator=_cursor_paginator(),
+ data_selector=_FEED_DATA_SELECTOR,
+ initial_paginator_state={"cursor": page_cursor} if page_cursor else None,
+ page_state_hook=remember_feed,
+ ):
+ next_page_cursor = next_feed.get("cursor")
+ uris = [post["uri"] for post in posts]
+ start = uris.index(resume_post) if resume_post in uris else 0
+ for index in range(start, len(uris)):
+ uri = uris[index]
+ if uri in seen:
+ continue
+ seen.add(uri)
+
+ if index + 1 < len(uris):
+ after_post: Optional[BlueskyResumeConfig] = BlueskyResumeConfig(
+ feed_cursor=page_cursor, post_uri=uris[index + 1]
+ )
+ elif next_page_cursor:
+ after_post = BlueskyResumeConfig(feed_cursor=next_page_cursor)
+ else:
+ after_post = None
+
+ child_cursor = resume_child_cursor if uri == resume_post else None
+ for rows in client.paginate(
+ path=config.path,
+ params={"uri": uri, "limit": 100},
+ paginator=_cursor_paginator(),
+ data_selector=config.data_selector,
+ initial_paginator_state={"cursor": child_cursor} if child_cursor else None,
+ page_state_hook=remember_child,
+ ):
+ if next_child.get("cursor"):
+ resumable_source_manager.save_state(
+ BlueskyResumeConfig(
+ feed_cursor=page_cursor, post_uri=uri, child_cursor=next_child["cursor"]
+ )
+ )
+ elif after_post is not None:
+ resumable_source_manager.save_state(after_post)
+
+ if rows:
+ yield [_fanout_row(endpoint, config, uri, row) for row in rows]
+ else:
+ resumable_source_manager.safe_point()
+
+ resume_post = None
+ resume_child_cursor = None
+ page_cursor = next_page_cursor
+ resumable_source_manager.safe_point()
+ finally:
+ client.session.close()
+
+
def bluesky_source(
actor: str,
endpoint: str,
@@ -92,16 +208,16 @@ def bluesky_source(
job_id: str,
resumable_source_manager: ResumableSourceManager[BlueskyResumeConfig],
) -> Resource:
+ resume_config = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+
config: RESTAPIConfig = {
"client": {"base_url": BASE_URL},
"resources": [get_resource(endpoint, actor)],
}
initial_paginator_state: Optional[dict[str, Any]] = None
- if resumable_source_manager.can_resume():
- resume_config = resumable_source_manager.load_state()
- if resume_config is not None:
- initial_paginator_state = {"cursor": resume_config.cursor}
+ if resume_config is not None and resume_config.cursor:
+ initial_paginator_state = {"cursor": resume_config.cursor}
def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
# Only persist when there's a next page to resume to; the Redis TTL handles cleanup on
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/canonical_descriptions.py
index 61dd90868754..de60abeada78 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/canonical_descriptions.py
@@ -66,4 +66,31 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"indexedAt": "Time the AppView last indexed the followed account's profile.",
},
},
+ "Likes": {
+ "description": "Likes on each post in the configured account's feed, one row per liking account.",
+ "docs_url": "https://docs.bsky.app/docs/api/app-bsky-feed-get-likes",
+ "columns": {
+ "post_uri": "AT-URI of the liked post.",
+ "actor_did": "Decentralized identifier of the account that liked the post.",
+ "actor": "Profile of the account that liked the post.",
+ "createdAt": "Time the like record was created, as set by the liking account.",
+ "indexedAt": "Time the AppView indexed the like.",
+ },
+ },
+ "Quotes": {
+ "description": "Posts that quote a post in the configured account's feed.",
+ "docs_url": "https://docs.bsky.app/docs/api/app-bsky-feed-get-quotes",
+ "columns": {
+ "quoted_post_uri": "AT-URI of the quoted post from the configured account's feed.",
+ "uri": "The quote post's AT-URI, globally unique across the network.",
+ "cid": "The quote post record's content hash.",
+ "author": "Profile of the quote post's author.",
+ "record": "The raw quote post record, including its text and creation time.",
+ "replyCount": "Number of replies to the quote post.",
+ "repostCount": "Number of reposts of the quote post.",
+ "likeCount": "Number of likes on the quote post.",
+ "quoteCount": "Number of quote posts of the quote post.",
+ "indexedAt": "Time the AppView first indexed the quote post.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/settings.py
index 115b57230f3e..08e488e4f78c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/settings.py
@@ -1,3 +1,5 @@
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.types import IncrementalField
# Bluesky's public AppView (see `bluesky.py`). No auth is required for any of the endpoints below.
@@ -8,8 +10,29 @@ ENDPOINTS = (
"Posts",
"Followers",
"Follows",
+ "Likes",
+ "Quotes",
)
+
+@frozen
+class PostFanoutEndpoint:
+ path: str
+ data_selector: str
+ # Column the parent post's AT-URI lands in on each child row.
+ parent_uri_column: str
+
+
+# These tables call their endpoint once per post in the `Posts` feed, since both take a single post URI.
+POST_FANOUT_ENDPOINTS: dict[str, PostFanoutEndpoint] = {
+ "Likes": PostFanoutEndpoint(
+ path="/xrpc/app.bsky.feed.getLikes", data_selector="likes", parent_uri_column="post_uri"
+ ),
+ "Quotes": PostFanoutEndpoint(
+ path="/xrpc/app.bsky.feed.getQuotes", data_selector="posts", parent_uri_column="quoted_post_uri"
+ ),
+}
+
# None of these endpoints expose a server-side timestamp filter (e.g. `since`/`updated_after`) --
# they only support opaque cursor pagination -- so every table syncs as a full refresh. Per the
# incremental sync guidance, a client-side "stop when we've seen this id before" cursor would still
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/source.py
index 592f5cc125cb..8487c5d1aad1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/source.py
@@ -11,11 +11,13 @@ from products.warehouse_sources.backend.facade.source_config import (
from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.bluesky import (
BlueskyResumeConfig,
bluesky_source,
+ post_fanout_rows,
validate_credentials as validate_bluesky_credentials,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.settings import (
ENDPOINTS,
INCREMENTAL_FIELDS,
+ POST_FANOUT_ENDPOINTS,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
@@ -34,12 +36,15 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
from products.warehouse_sources.backend.types import ExternalDataSourceType
# Every table is keyed on the id the AT Protocol guarantees is globally unique: post AT-URIs are
-# scoped by the author's own DID, and account DIDs are unique across the whole network.
+# scoped by the author's own DID, and account DIDs are unique across the whole network. Post
+# fan-out tables also carry the parent post's URI, since one account can like many posts.
PRIMARY_KEYS: dict[str, list[str]] = {
"Profile": ["did"],
"Posts": ["uri"],
"Followers": ["did"],
"Follows": ["did"],
+ "Likes": ["post_uri", "actor_did"],
+ "Quotes": ["quoted_post_uri", "uri"],
}
# Stable, top-level datetime fields only (see partition-key-stability guidance): `indexedAt` is
@@ -51,6 +56,8 @@ PARTITION_FIELDS: dict[str, list[str]] = {
"Posts": ["indexedAt"],
"Followers": ["createdAt"],
"Follows": ["createdAt"],
+ "Likes": ["indexedAt"],
+ "Quotes": ["indexedAt"],
}
@@ -117,6 +124,16 @@ class BlueskySource(ResumableSource[BlueskySourceConfig, BlueskyResumeConfig]):
resumable_source_manager: ResumableSourceManager[BlueskyResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
+ partition_keys = PARTITION_FIELDS.get(inputs.schema_name)
+ if inputs.schema_name in POST_FANOUT_ENDPOINTS:
+ return SourceResponse(
+ name=inputs.schema_name,
+ items=lambda: post_fanout_rows(config.actor, inputs.schema_name, resumable_source_manager),
+ primary_keys=PRIMARY_KEYS[inputs.schema_name],
+ partition_mode="datetime",
+ partition_keys=partition_keys,
+ )
+
resource = bluesky_source(
actor=config.actor,
endpoint=inputs.schema_name,
@@ -124,7 +141,6 @@ class BlueskySource(ResumableSource[BlueskySourceConfig, BlueskyResumeConfig]):
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
)
- partition_keys = PARTITION_FIELDS.get(inputs.schema_name)
return SourceResponse(
name=resource.name,
items=lambda: resource,
@@ -141,7 +157,8 @@ class BlueskySource(ResumableSource[BlueskySourceConfig, BlueskyResumeConfig]):
category=DataWarehouseSourceCategory.MARKETING___EMAIL,
label="Bluesky",
caption=(
- "Sync a Bluesky account's profile, posts, followers, and follows. Uses Bluesky's "
+ "Sync a Bluesky account's profile, posts, followers, follows, and the likes and quotes "
+ "on its posts. Uses Bluesky's "
"public AppView API, so you only need the handle or DID you want to track, not an "
"account password or app password."
),
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/tests/test_bluesky.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/tests/test_bluesky.py
index 2755f75782e4..4d9b431bd183 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/tests/test_bluesky.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bluesky/tests/test_bluesky.py
@@ -1,3 +1,4 @@
+from collections.abc import Callable
from typing import Any
import pytest
@@ -7,8 +8,9 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.bl
get_resource,
validate_credentials,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.source import BlueskySource
+from products.warehouse_sources.backend.temporal.data_imports.sources.bluesky.source import PRIMARY_KEYS, BlueskySource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (
+ RecordedRequest,
ScriptedResponse,
SourceDriver,
always,
@@ -117,3 +119,117 @@ class TestBlueskySourceResumeBehavior:
assert result.raised is None
assert result.items == [[{"uri": "at://x", "indexedAt": "2026-01-01T00:00:00Z"}]]
+
+
+POST_1 = "at://did:plc:abc/app.bsky.feed.post/1"
+# A did:web AT-URI can carry a percent-encoded port, which must reach the API unchanged.
+POST_2 = "at://did:web:example.com%3A8080/app.bsky.feed.post/2"
+
+
+def _post_fanout_script(
+ list_key: str, child_row: Callable[[int], dict[str, Any]]
+) -> Callable[[RecordedRequest], ScriptedResponse]:
+ def respond(request: RecordedRequest) -> ScriptedResponse:
+ if request.path.endswith("getAuthorFeed"):
+ if request.param("cursor") is None:
+ return ScriptedResponse(json={"feed": [{"post": {"uri": POST_1}}], "cursor": "feed-2"})
+ return ScriptedResponse(json={"feed": [{"post": {"uri": POST_2}}]})
+ if request.param("cursor") is None:
+ body: dict[str, Any] = {list_key: [child_row(1)]}
+ if request.param("uri") == POST_1:
+ body["cursor"] = "child-2"
+ return ScriptedResponse(json=body)
+ return ScriptedResponse(json={list_key: [child_row(2)]})
+
+ return respond
+
+
+POST_FANOUT_CASES = [
+ (
+ "Likes",
+ "likes",
+ lambda n: {"actor": {"did": f"did:plc:liker{n}"}, "indexedAt": "2026-01-01T00:00:00Z"},
+ [(POST_1, "did:plc:liker1"), (POST_1, "did:plc:liker2"), (POST_2, "did:plc:liker1")],
+ ),
+ (
+ "Quotes",
+ "posts",
+ lambda n: {"uri": f"at://did:plc:quoter/app.bsky.feed.post/{n}", "indexedAt": "2026-01-01T00:00:00Z"},
+ [
+ (POST_1, "at://did:plc:quoter/app.bsky.feed.post/1"),
+ (POST_1, "at://did:plc:quoter/app.bsky.feed.post/2"),
+ (POST_2, "at://did:plc:quoter/app.bsky.feed.post/1"),
+ ],
+ ),
+]
+
+
+class TestBlueskyPostFanout:
+ @staticmethod
+ def _driver() -> SourceDriver:
+ return SourceDriver(BlueskySource(), BlueskySourceConfig(actor="jay.bsky.team"))
+
+ @pytest.mark.parametrize(("endpoint", "list_key", "child_row", "expected_keys"), POST_FANOUT_CASES)
+ def test_walks_every_post_and_child_page(
+ self,
+ endpoint: str,
+ list_key: str,
+ child_row: Callable[[int], dict[str, Any]],
+ expected_keys: list[tuple[str, str]],
+ ) -> None:
+ result = self._driver().run(endpoint, _post_fanout_script(list_key, child_row))
+
+ assert result.raised is None
+ assert [tuple(row[key] for key in PRIMARY_KEYS[endpoint]) for row in result.rows] == expected_keys
+ child_requests = [r for r in result.requests if not r.path.endswith("getAuthorFeed")]
+ assert [(r.param("uri"), r.param("cursor")) for r in child_requests] == [
+ (POST_1, None),
+ (POST_1, "child-2"),
+ (POST_2, None),
+ ]
+
+ @pytest.mark.parametrize(("endpoint", "list_key", "child_row", "expected_keys"), POST_FANOUT_CASES)
+ @pytest.mark.parametrize(
+ ("resume_state", "expected_child_requests", "expected_rows"),
+ [
+ (
+ BlueskyResumeConfig(post_uri=POST_1, child_cursor="child-2"),
+ [(POST_1, "child-2"), (POST_2, None)],
+ slice(1, None),
+ ),
+ (BlueskyResumeConfig(feed_cursor="feed-2"), [(POST_2, None)], slice(2, None)),
+ ],
+ )
+ def test_resume_continues_from_saved_position(
+ self,
+ endpoint: str,
+ list_key: str,
+ child_row: Callable[[int], dict[str, Any]],
+ expected_keys: list[tuple[str, str]],
+ resume_state: BlueskyResumeConfig,
+ expected_child_requests: list[tuple[str, str | None]],
+ expected_rows: slice,
+ ) -> None:
+ result = self._driver().run(endpoint, _post_fanout_script(list_key, child_row), resume_state=resume_state)
+
+ assert result.raised is None
+ child_requests = [r for r in result.requests if not r.path.endswith("getAuthorFeed")]
+ assert [(r.param("uri"), r.param("cursor")) for r in child_requests] == expected_child_requests
+ assert [tuple(row[key] for key in PRIMARY_KEYS[endpoint]) for row in result.rows] == expected_keys[
+ expected_rows
+ ]
+
+ @pytest.mark.parametrize(("endpoint", "list_key", "child_row", "expected_keys"), POST_FANOUT_CASES)
+ def test_saves_fixed_size_position_before_each_child_page(
+ self,
+ endpoint: str,
+ list_key: str,
+ child_row: Callable[[int], dict[str, Any]],
+ expected_keys: list[tuple[str, str]],
+ ) -> None:
+ result = self._driver().run(endpoint, _post_fanout_script(list_key, child_row))
+
+ assert result.saved_states == [
+ BlueskyResumeConfig(post_uri=POST_1, child_cursor="child-2"),
+ BlueskyResumeConfig(feed_cursor="feed-2"),
+ ]