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): add monday board columns, groups, activity logs and folders (#115458)

Tom Owers8000d17b4e90
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 e8be954667c9..1d2f6d6eddfd 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
@@ -5691,18 +5691,18 @@ Note: Spec is the vendor's single-file OpenAPI (mollie/openapi repo, ~1.9 MB). C
## Monday — gaps
-Today (4): `boards`, `items`, `users`, `workspaces`
+Today (8): `board_activity_logs`, `board_columns`, `board_groups`, `boards`, `folders`, `items`, `users`, `workspaces`
Diffed against: <https://raw.githubusercontent.com/mondaycom/monday-graphql-api/main/packages/api-types/generated/api-types.d.ts>
-- [ ] `boards { columns { id title type settings_str } }` — lookup that resolves the column ids inside every item's column_values — today those columns are unlabeled (high)
-- [ ] `boards { activity_logs }` — board change history (status transitions, moves, assignments) — the only source of state-transition data (high)
-- [ ] `boards { groups { id title } }` — lookup for the group ids items belong to, including groups with no items (medium)
+- [x] `boards { columns { id title type settings_str } }` — lookup that resolves the column ids inside every item's column_values — today those columns are unlabeled (high)
+- [x] `boards { activity_logs }` — board change history (status transitions, moves, assignments) — the only source of state-transition data (high)
+- [x] `boards { groups { id title } }` — lookup for the group ids items belong to, including groups with no items (medium)
- [ ] `updates` — comments/updates on items — the collaboration activity stream (medium)
- [ ] `teams` — team objects plus their users — resolves team owners/subscribers on boards (medium)
- [ ] `boards { subscribers owners team_owners }` — board membership join table; boards currently sync with no ownership data (medium)
- [ ] `tags` — tag lookup resolving tag ids stored in item column values (medium)
-- [ ] `folders` — workspace folder hierarchy that boards hang off via board_folder_id (medium)
+- [x] `folders` — workspace folder hierarchy that boards hang off via board_folder_id (medium)
- [ ] `items { subitems }` — subitems live on separate boards and are missed by the current board-items walk (medium)
- [ ] `docs` — workspace docs objects for content coverage alongside boards (low)
- [ ] `boards { views }` — board view inventory for usage analysis (low)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/canonical_descriptions.py
index d9e85318b4c6..238a1108fb4c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/canonical_descriptions.py
@@ -68,4 +68,59 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"created_at": "Time at which the workspace was created.",
},
},
+ "folders": {
+ "description": "A folder in a monday.com workspace that organizes boards, dashboards, and docs.",
+ "docs_url": "https://developer.monday.com/api-reference/reference/folders",
+ "columns": {
+ "id": "Unique identifier for the folder. Boards reference it through board_folder_id.",
+ "name": "The folder's name.",
+ "color": "The folder's color.",
+ "created_at": "The folder's creation date.",
+ "owner_id": "Identifier of the user who owns the folder.",
+ "parent": "The folder's parent folder, if it is a sub-folder.",
+ "workspace": "The workspace that contains the folder (null id for the main workspace).",
+ },
+ },
+ "board_columns": {
+ "description": "A column on a monday.com board. Resolves the column ids used in each item's column_values.",
+ "docs_url": "https://developer.monday.com/api-reference/reference/columns",
+ "columns": {
+ "id": "The column's identifier, unique within its board.",
+ "_board_id": "Identifier of the board the column belongs to.",
+ "title": "The column's title.",
+ "type": "The column's type, such as status, date, people, or numbers.",
+ "description": "The column's description.",
+ "archived": "Whether the column is archived.",
+ "width": "The column's width in pixels.",
+ "settings": "The column's type-specific settings as JSON, such as status labels and colors.",
+ "settings_str": "The column's settings as a JSON string (API versions before 2025-10).",
+ },
+ },
+ "board_groups": {
+ "description": "A group of items on a monday.com board.",
+ "docs_url": "https://developer.monday.com/api-reference/reference/groups",
+ "columns": {
+ "id": "The group's identifier, unique within its board.",
+ "_board_id": "Identifier of the board the group belongs to.",
+ "title": "The group's title.",
+ "color": "The group's color.",
+ "position": "The group's position on the board.",
+ "archived": "Whether the group is archived.",
+ "deleted": "Whether the group is deleted.",
+ },
+ },
+ "board_activity_logs": {
+ "description": "An activity log event on a monday.com board, such as a status change, item move, or assignment.",
+ "docs_url": "https://developer.monday.com/api-reference/reference/activity-logs",
+ "columns": {
+ "id": "Unique identifier for the activity log event.",
+ "_board_id": "Identifier of the board the event happened on.",
+ "event": "The action that took place.",
+ "entity": "The entity the event changed: board or pulse (item).",
+ "data": "JSON string with the event details, such as the previous and new column values.",
+ "user_id": "Identifier of the user who initiated the event.",
+ "account_id": "Identifier of the account that initiated the event.",
+ "created_at": "Time at which the event happened.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
index 7e15ac784d2a..e69838544b45 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
@@ -1,4 +1,5 @@
from collections.abc import Iterator
+from datetime import UTC, date, datetime
from typing import Any, Optional
import requests
@@ -18,9 +19,16 @@ MONDAY_API_VERSION_HEADERS: dict[str, str] = {
MONDAY_VERSION_V2: "2024-10",
MONDAY_VERSION_2026_07: "2026-07",
}
-# Boards/users page size; items_page caps at 500.
+# 2024-10 serves column settings as `settings_str`; 2026-07 documents only the `settings` JSON field.
+MONDAY_COLUMN_SETTINGS_FIELDS: dict[str, str] = {
+ MONDAY_VERSION_V2: "settings_str",
+ MONDAY_VERSION_2026_07: "settings",
+}
+# Boards/users/folders page size; items_page caps at 500.
PAGE_SIZE = 100
ITEMS_PAGE_SIZE = 500
+# activity_logs accepts up to 10,000 per request; a smaller page keeps each query's complexity low.
+ACTIVITY_LOGS_PAGE_SIZE = 1000
REQUEST_TIMEOUT_SECONDS = 120
# Rate limiting is complexity-budget based (5-10M points/min by tier) and
# surfaces as a GraphQL error (not a 429); exponential backoff rides out the minute window.
@@ -35,6 +43,7 @@ query ($limit: Int!, $page: Int!) {
state
description
workspace_id
+ board_folder_id
item_terminology
items_count
permissions
@@ -74,6 +83,45 @@ query ($limit: Int!, $page: Int!) {
}
"""
+_FOLDERS_QUERY = """
+query ($limit: Int!, $page: Int!, $workspaceIds: [ID]) {
+ folders (limit: $limit, page: $page, workspace_ids: $workspaceIds) {
+ id
+ name
+ color
+ created_at
+ owner_id
+ parent { id }
+ workspace { id }
+ }
+}
+"""
+
+_BOARD_GROUPS_QUERY = """
+query ($limit: Int!, $page: Int!) {
+ boards (limit: $limit, page: $page) {
+ id
+ groups { id title color position archived deleted }
+ }
+}
+"""
+
+_BOARD_ACTIVITY_LOGS_QUERY = """
+query ($boardId: [ID!], $limit: Int!, $page: Int!, $from: ISO8601DateTime) {
+ boards (ids: $boardId) {
+ activity_logs (limit: $limit, page: $page, from: $from) {
+ id
+ event
+ entity
+ data
+ user_id
+ account_id
+ created_at
+ }
+ }
+}
+"""
+
_ITEM_FIELDS = """
id
name
@@ -116,6 +164,35 @@ query ($cursor: String!, $limit: Int!) {{
"""
+def _board_columns_query(api_version: str) -> str:
+ return f"""
+query ($limit: Int!, $page: Int!) {{
+ boards (limit: $limit, page: $page) {{
+ id
+ columns {{ id title type description archived width {MONDAY_COLUMN_SETTINGS_FIELDS[api_version]} }}
+ }}
+}}
+"""
+
+
+def _format_from(value: Any) -> str:
+ # Truncating to whole seconds keeps the inclusive `from` bound at or before the watermark.
+ if isinstance(value, datetime):
+ utc_value = value.replace(tzinfo=UTC) if value.tzinfo is None else value.astimezone(UTC)
+ return utc_value.strftime("%Y-%m-%dT%H:%M:%SZ")
+ if isinstance(value, date):
+ return f"{value.isoformat()}T00:00:00Z"
+ return str(value)
+
+
+def _parse_activity_log_created_at(value: Any) -> Any:
+ # Activity log timestamps are 17-digit Unix time (100-nanosecond units) serialized as a string.
+ try:
+ return datetime.fromtimestamp(int(value) / 10_000_000, tz=UTC)
+ except (TypeError, ValueError):
+ return value
+
+
class MondayRetryableError(Exception):
pass
@@ -204,6 +281,8 @@ def get_rows(
endpoint: str,
logger: FilteringBoundLogger,
api_version: str,
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
) -> Iterator[list[dict[str, Any]]]:
session = _get_session(api_token, api_version)
@@ -216,10 +295,12 @@ def get_rows(
def execute(query: str, variables: dict[str, Any]) -> dict[str, Any]:
return _execute(session, query, variables, logger)
- def iterate_paged(query: str, data_key: str) -> Iterator[list[dict[str, Any]]]:
+ def iterate_paged(
+ query: str, data_key: str, extra_variables: Optional[dict[str, Any]] = None
+ ) -> Iterator[list[dict[str, Any]]]:
page = 1
while True:
- data = execute(query, {"limit": PAGE_SIZE, "page": page})
+ data = execute(query, {"limit": PAGE_SIZE, "page": page, **(extra_variables or {})})
items = data.get(data_key) or []
if items:
yield items
@@ -227,6 +308,20 @@ def get_rows(
return
page += 1
+ def iterate_board_children(query: str, child_key: str) -> Iterator[list[dict[str, Any]]]:
+ for boards in iterate_paged(query, "boards"):
+ rows = [
+ {**child, "_board_id": board["id"]}
+ for board in boards
+ for child in (board.get(child_key) or [])
+ if child is not None
+ ]
+ if rows:
+ yield rows
+
+ def board_ids() -> list[str]:
+ return [board["id"] for page in iterate_paged(_BOARD_IDS_QUERY, "boards") for board in page]
+
if endpoint == "boards":
yield from iterate_paged(_BOARDS_QUERY, "boards")
return
@@ -239,10 +334,52 @@ def get_rows(
yield from iterate_paged(_WORKSPACES_QUERY, "workspaces")
return
- # items: fan out over every board, then walk its items_page cursor chain.
- board_ids = [board["id"] for page in iterate_paged(_BOARD_IDS_QUERY, "boards") for board in page]
+ if endpoint == "board_columns":
+ yield from iterate_board_children(_board_columns_query(api_version), "columns")
+ return
+
+ if endpoint == "board_groups":
+ yield from iterate_board_children(_BOARD_GROUPS_QUERY, "groups")
+ return
- for board_id in board_ids:
+ if endpoint == "folders":
+ # monday documents `workspace_ids: [null]` as the way to reach the main workspace, so walk it
+ # and then each workspace explicitly instead of relying on the unfiltered query.
+ workspace_ids = [ws["id"] for page in iterate_paged(_WORKSPACES_QUERY, "workspaces") for ws in page]
+ seen_folder_ids: set[str] = set()
+ for workspace_id in [None, *workspace_ids]:
+ for folders in iterate_paged(_FOLDERS_QUERY, "folders", {"workspaceIds": [workspace_id]}):
+ new_folders = [f for f in folders if f["id"] not in seen_folder_ids]
+ seen_folder_ids.update(f["id"] for f in new_folders)
+ if new_folders:
+ yield new_folders
+ return
+
+ if endpoint == "board_activity_logs":
+ variables: dict[str, Any] = {"limit": ACTIVITY_LOGS_PAGE_SIZE}
+ if should_use_incremental_field and db_incremental_field_last_value is not None:
+ variables["from"] = _format_from(db_incremental_field_last_value)
+
+ for board_id in board_ids():
+ page = 1
+ while True:
+ data = execute(_BOARD_ACTIVITY_LOGS_QUERY, {**variables, "boardId": [board_id], "page": page})
+ boards = data.get("boards") or []
+ logs = (boards[0].get("activity_logs") if boards else None) or []
+ rows = [
+ {**log, "created_at": _parse_activity_log_created_at(log.get("created_at")), "_board_id": board_id}
+ for log in logs
+ if log is not None
+ ]
+ if rows:
+ yield rows
+ if len(logs) < ACTIVITY_LOGS_PAGE_SIZE:
+ break
+ page += 1
+ return
+
+ # items: fan out over every board, then walk its items_page cursor chain.
+ for board_id in board_ids():
data = execute(_ITEMS_PAGE_QUERY, {"boardId": [board_id], "limit": ITEMS_PAGE_SIZE})
boards = data.get("boards") or []
items_page = (boards[0].get("items_page") if boards else None) or {}
@@ -265,6 +402,8 @@ def monday_source(
endpoint: str,
logger: FilteringBoundLogger,
api_version: str,
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
) -> SourceResponse:
config = MONDAY_ENDPOINTS[endpoint]
@@ -275,9 +414,14 @@ def monday_source(
endpoint=endpoint,
logger=logger,
api_version=api_version,
+ should_use_incremental_field=should_use_incremental_field,
+ db_incremental_field_last_value=db_incremental_field_last_value,
),
primary_keys=config.primary_keys,
partition_count=1,
partition_size=1,
- sort_mode="asc",
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="month" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ sort_mode=config.sort_mode,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/settings.py
index be962500dcf0..661afb7a1d0f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/settings.py
@@ -1,16 +1,24 @@
-from dataclasses import dataclass, field
+from dataclasses import field
+from posthog.dataclasses import frozen
-@dataclass
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SortMode
+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
+
+
+@frozen
class MondayEndpointConfig:
name: str
primary_keys: list[str] = field(default_factory=lambda: ["id"])
+ incremental_fields: list[IncrementalField] = field(default_factory=list)
+ sort_mode: SortMode = "asc"
+ partition_key: str | None = None
# monday.com is GraphQL-only. List queries have no honest updated-since
-# filtering (incremental would need the activity log, whose retention window is
-# plan-dependent), so every stream is a full refresh. Items use cursor paging
-# whose cursors expire after 60 minutes, so nothing is persisted across runs.
+# filtering, so every stream except the board activity log is a full refresh.
+# Items use cursor paging whose cursors expire after 60 minutes, so nothing is
+# persisted across runs.
MONDAY_ENDPOINTS: dict[str, MondayEndpointConfig] = {
"boards": MondayEndpointConfig(
name="boards",
@@ -27,6 +35,34 @@ MONDAY_ENDPOINTS: dict[str, MondayEndpointConfig] = {
"workspaces": MondayEndpointConfig(
name="workspaces",
),
+ "folders": MondayEndpointConfig(
+ name="folders",
+ ),
+ # Column and group ids are only unique within their board.
+ "board_columns": MondayEndpointConfig(
+ name="board_columns",
+ primary_keys=["_board_id", "id"],
+ ),
+ "board_groups": MondayEndpointConfig(
+ name="board_groups",
+ primary_keys=["_board_id", "id"],
+ ),
+ # `activity_logs(from:)` filters server-side, but each board returns its log
+ # newest first. Retention of the log itself depends on the monday.com plan.
+ "board_activity_logs": MondayEndpointConfig(
+ name="board_activity_logs",
+ primary_keys=["_board_id", "id"],
+ incremental_fields=[
+ {
+ "label": "created_at",
+ "type": IncrementalFieldType.DateTime,
+ "field": "created_at",
+ "field_type": IncrementalFieldType.DateTime,
+ },
+ ],
+ sort_mode="desc",
+ partition_key="created_at",
+ ),
}
ENDPOINTS = tuple(MONDAY_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
index 5fa646161c99..878ce4758946 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
@@ -26,7 +26,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.monday.mon
monday_source,
validate_credentials as validate_monday_credentials,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.monday.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.monday.settings import ENDPOINTS, MONDAY_ENDPOINTS
from products.warehouse_sources.backend.types import ExternalDataSourceType
@@ -106,14 +106,14 @@ You can find your personal API token in monday.com under your avatar > Developer
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
- # GraphQL list queries have no honest updated-since filter (incremental
- # would need the plan-limited activity log), so full refresh only.
+ # Only the board activity log has a server-side time filter; every other
+ # GraphQL list query is full refresh only.
schemas = [
SourceSchema(
name=endpoint,
- supports_incremental=False,
+ supports_incremental=bool(MONDAY_ENDPOINTS[endpoint].incremental_fields),
supports_append=False,
- incremental_fields=[],
+ incremental_fields=MONDAY_ENDPOINTS[endpoint].incremental_fields,
)
for endpoint in ENDPOINTS
]
@@ -142,4 +142,6 @@ You can find your personal API token in monday.com under your avatar > Developer
endpoint=inputs.schema_name,
logger=inputs.logger,
api_version=self.resolve_api_version(inputs.api_version),
+ should_use_incremental_field=inputs.should_use_incremental_field,
+ db_incremental_field_last_value=inputs.db_incremental_field_last_value,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
index 0ef7d16f42a5..2fc05f76b0e7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
@@ -1,9 +1,19 @@
+import json
+from datetime import UTC, datetime
from typing import Any
import pytest
from unittest import mock
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (
+ RecordedRequest,
+ ScriptedResponse,
+ SourceDriver,
+ scripted_network,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.monday import MondaySourceConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday import (
+ ACTIVITY_LOGS_PAGE_SIZE,
ITEMS_PAGE_SIZE,
MONDAY_VERSION_2026_07,
MONDAY_VERSION_V2,
@@ -13,6 +23,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.monday.mon
get_rows,
validate_credentials,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.monday.source import MondaySource
+from products.warehouse_sources.backend.types import IncrementalFieldType
_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday"
API_VERSION = MONDAY_VERSION_2026_07
@@ -142,3 +154,103 @@ class TestGetRowsItems:
assert all(item["_board_id"] == "b1" for item in flat)
next_vars = mock_session.return_value.post.call_args_list[2].kwargs["json"]["variables"]
assert next_vars == {"cursor": "cur1", "limit": ITEMS_PAGE_SIZE}
+
+
+def _graphql(request: RecordedRequest) -> dict[str, Any]:
+ assert request.body is not None
+ return json.loads(request.body)
+
+
+def _driver() -> SourceDriver:
+ return SourceDriver(MondaySource(), MondaySourceConfig(api_token="token"))
+
+
+class TestGetRowsBoardChildren:
+ @pytest.mark.parametrize(
+ "endpoint, child_key",
+ [("board_columns", "columns"), ("board_groups", "groups")],
+ )
+ def test_children_carry_their_board_across_board_pages(self, endpoint, child_key):
+ first_page = [{"id": "b1", child_key: [{"id": "status"}, None]}] + [
+ {"id": f"empty{i}", child_key: []} for i in range(PAGE_SIZE - 1)
+ ]
+ script = [
+ ScriptedResponse(json={"data": {"boards": first_page}}),
+ ScriptedResponse(json={"data": {"boards": [{"id": "b2", child_key: [{"id": "status"}]}]}}),
+ ]
+
+ result = _driver().run(endpoint, script)
+
+ assert result.raised is None
+ assert result.rows == [{"id": "status", "_board_id": "b1"}, {"id": "status", "_board_id": "b2"}]
+ assert [_graphql(r)["variables"] for r in result.requests] == [
+ {"limit": PAGE_SIZE, "page": 1},
+ {"limit": PAGE_SIZE, "page": 2},
+ ]
+
+ @pytest.mark.parametrize(
+ "api_version, requested_field, absent_field",
+ [
+ (MONDAY_VERSION_V2, "settings_str", " settings "),
+ (MONDAY_VERSION_2026_07, " settings ", "settings_str"),
+ ],
+ )
+ def test_columns_request_the_settings_field_the_pinned_version_serves(
+ self, api_version, requested_field, absent_field
+ ):
+ with scripted_network([ScriptedResponse(json={"data": {"boards": []}})]) as network:
+ list(get_rows("token", "board_columns", mock.MagicMock(), api_version))
+
+ query = _graphql(network.requests_log[0])["query"]
+ assert requested_field in query
+ assert absent_field not in query
+
+
+class TestGetRowsFolders:
+ def test_walks_main_and_every_workspace_without_duplicating_folders(self):
+ script = [
+ ScriptedResponse(json={"data": {"workspaces": [{"id": "w1"}]}}),
+ ScriptedResponse(json={"data": {"folders": [{"id": "f1"}]}}),
+ ScriptedResponse(json={"data": {"folders": [{"id": "f1"}, {"id": "f2"}]}}),
+ ]
+
+ result = _driver().run("folders", script)
+
+ assert result.raised is None
+ assert [row["id"] for row in result.rows] == ["f1", "f2"]
+ assert [_graphql(r)["variables"].get("workspaceIds") for r in result.requests] == [None, [None], ["w1"]]
+
+
+class TestGetRowsBoardActivityLogs:
+ @pytest.mark.parametrize(
+ "incremental_inputs, expected_from",
+ [
+ ({}, None),
+ (
+ {
+ "incremental_field": "created_at",
+ "incremental_field_type": IncrementalFieldType.DateTime,
+ "db_incremental_field_last_value": datetime(2026, 1, 2, 3, 4, 5, 678000, tzinfo=UTC),
+ },
+ "2026-01-02T03:04:05Z",
+ ),
+ ],
+ )
+ def test_pages_each_board_and_sends_the_watermark_only_when_incremental(self, incremental_inputs, expected_from):
+ full_page = [{"id": f"log{i}", "created_at": "17000000000000000"} for i in range(ACTIVITY_LOGS_PAGE_SIZE)]
+ script = [
+ ScriptedResponse(json={"data": {"boards": [{"id": "b1"}, {"id": "b2"}]}}),
+ ScriptedResponse(json={"data": {"boards": [{"activity_logs": full_page}]}}),
+ ScriptedResponse(json={"data": {"boards": [{"activity_logs": [{"id": "tail", "created_at": "bad"}]}]}}),
+ ScriptedResponse(json={"data": {"boards": [{"activity_logs": []}]}}),
+ ]
+
+ result = _driver().run("board_activity_logs", script, **incremental_inputs)
+
+ assert result.raised is None
+ assert len(result.rows) == ACTIVITY_LOGS_PAGE_SIZE + 1
+ assert result.rows[0]["created_at"] == datetime(2023, 11, 14, 22, 13, 20, tzinfo=UTC)
+ assert result.rows[-1] == {"id": "tail", "created_at": "bad", "_board_id": "b1"}
+ log_variables = [_graphql(r)["variables"] for r in result.requests[1:]]
+ assert [(v["boardId"], v["page"]) for v in log_variables] == [(["b1"], 1), (["b1"], 2), (["b2"], 1)]
+ assert {v.get("from") for v in log_variables} == {expected_from}