Skip to content

Commit 403a5cb

Browse files
authored
🐛 Source Monday: fetch display value when text is empty (#37722)
1 parent c850c6e commit 403a5cb

File tree

7 files changed

+60
-59
lines changed

7 files changed

+60
-59
lines changed

airbyte-integrations/connectors/source-monday/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data:
1010
connectorSubtype: api
1111
connectorType: source
1212
definitionId: 80a54ea2-9959-4040-aac1-eee42423ec9b
13-
dockerImageTag: 2.1.1
13+
dockerImageTag: 2.1.2
1414
releases:
1515
breakingChanges:
1616
2.0.0:

airbyte-integrations/connectors/source-monday/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "2.1.1"
6+
version = "2.1.2"
77
name = "source-monday"
88
description = "Source implementation for Monday."
99
authors = [ "Airbyte <[email protected]>",]

airbyte-integrations/connectors/source-monday/source_monday/extractor.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,14 @@ def extract_records(self, response: requests.Response) -> List[Record]:
105105
if not result and self.field_path_incremental:
106106
result = self.try_extract_records(response, self.field_path_incremental)
107107

108-
for item_index in range(len(result)):
109-
if "updated_at" in result[item_index]:
110-
result[item_index]["updated_at_int"] = int(
111-
datetime.strptime(result[item_index]["updated_at"], "%Y-%m-%dT%H:%M:%S%z").timestamp()
112-
)
108+
for record in result:
109+
if "updated_at" in record:
110+
record["updated_at_int"] = int(datetime.strptime(record["updated_at"], "%Y-%m-%dT%H:%M:%S%z").timestamp())
111+
112+
column_values = record.get("column_values", [])
113+
for values in column_values:
114+
display_value, text = values.get("display_value"), values.get("text")
115+
if display_value and not text:
116+
values["text"] = display_value
117+
113118
return result

airbyte-integrations/connectors/source-monday/source_monday/graphql_requester.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,14 @@ def _build_query(self, object_name: str, field_schema: dict, **object_arguments)
7777

7878
arguments = self._get_object_arguments(**object_arguments)
7979
arguments = f"({arguments})" if arguments else ""
80-
fields = ",".join(fields)
8180

82-
# Essentially, we construct a query based on schema properties; however, some fields in the schema are conditional.
83-
# These conditional fields can be obtained by defining them as inline fragments (The docs: https://spec.graphql.org/October2021/#sec-Inline-Fragments).
84-
# This is an example of a query built for the Items stream, with a `display_value` property defined as an `MirrorValue` inline fragment:
85-
# query {
86-
# boards (limit:1) {
87-
# items_page (limit:20) {
88-
# <a field>,
89-
# ...,
90-
# column_values {
91-
# id,
92-
# text,
93-
# type,
94-
# value,
95-
# ... on MirrorValue {display_value}
96-
# }
97-
# }
98-
# }
99-
# }
100-
# When constructing a query, we replace the `display_value` field with the `... on MirrorValue {display_value}` inline fragment.
101-
if object_name == "column_values" and "display_value" in fields:
102-
fields = fields.replace("display_value", "... on MirrorValue{display_value}")
81+
if object_name == "column_values":
82+
fields.remove("display_value")
83+
fields.extend(
84+
["... on MirrorValue{display_value}", "... on BoardRelationValue{display_value}", "... on DependencyValue{display_value}"]
85+
)
86+
87+
fields = ",".join(fields)
10388

10489
if object_name in ["items_page", "next_items_page"]:
10590
query = f"{object_name}{arguments}{{cursor,items{{{fields}}}}}"

airbyte-integrations/connectors/source-monday/unit_tests/test_extractor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_empty_activity_logs_extract_records():
3838
def test_extract_records_incremental():
3939
# Mock the response
4040
response = MagicMock()
41-
response_body = {"data": {"boards": [{"id": 1}]}}
41+
response_body = {"data": {"boards": [{"id": 1, "column_values": [{"id": 11, "text": None, "display_value": "Hola amigo!"}]}]}}
4242

4343
response.json.return_value = response_body
4444
extractor = MondayIncrementalItemsExtractor(
@@ -51,4 +51,4 @@ def test_extract_records_incremental():
5151
records = extractor.extract_records(response)
5252

5353
# Assertions
54-
assert records == [{"id": 1}]
54+
assert records == [{"id": 1, "column_values": [{"id": 11, "text": "Hola amigo!", "display_value": "Hola amigo!"}]}]

airbyte-integrations/connectors/source-monday/unit_tests/test_graphql_requester.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,22 @@ def test_build_items_incremental_query(monday_requester):
145145
field_schema = {
146146
"id": {"type": "integer"},
147147
"name": {"type": "string"},
148+
"column_values": {
149+
"properties": {
150+
"id": {"type": ["null", "string"]},
151+
"text": {"type": ["null", "string"]},
152+
"type": {"type": ["null", "string"]},
153+
"value": {"type": ["null", "string"]},
154+
"display_value": {"type": ["null", "string"]}
155+
}
156+
}
148157
}
149158
stream_slice = {"ids": [1, 2, 3]}
150159

151160
built_query = monday_requester._build_items_incremental_query(object_name, field_schema, stream_slice)
152161

153-
assert built_query == "items(limit:100,ids:[1, 2, 3]){id,name}"
162+
assert built_query == "items(limit:100,ids:[1, 2, 3]){id,name,column_values{id,text,type,value,... on MirrorValue{display_value}," \
163+
"... on BoardRelationValue{display_value},... on DependencyValue{display_value}}}"
154164

155165

156166
def test_get_request_headers(monday_requester):

docs/integrations/sources/monday.md

+28-27
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,31 @@ The Monday connector should not run into Monday API limitations under normal usa
7272

7373
## Changelog
7474

75-
| Version | Date | Pull Request | Subject |
76-
|:--------|:-----------|:----------------------------------------------------------|:------------------------------------------------------------------------|
77-
| 2.1.1 | 2024-04-05 | [36717](https://github.com/airbytehq/airbyte/pull/36717) | Add handling of complexityBudgetExhausted error. |
78-
| 2.1.0 | 2024-04-03 | [36746](https://github.com/airbytehq/airbyte/pull/36746) | Pin airbyte-cdk version to `^0` |
79-
| 2.0.4 | 2024-02-28 | [35696](https://github.com/airbytehq/airbyte/pull/35696) | Fix extraction for `null` value in stream `Activity logs` |
80-
| 2.0.3 | 2024-02-21 | [35506](https://github.com/airbytehq/airbyte/pull/35506) | Support for column values of the mirror type for the `Items` stream. |
81-
| 2.0.2 | 2024-02-12 | [35146](https://github.com/airbytehq/airbyte/pull/35146) | Manage dependencies with Poetry. |
82-
| 2.0.1 | 2024-02-08 | [35016](https://github.com/airbytehq/airbyte/pull/35016) | Migrated to the latest airbyte cdk |
83-
| 2.0.0 | 2024-01-12 | [34108](https://github.com/airbytehq/airbyte/pull/34108) | Migrated to the latest API version: 2024-01 |
84-
| 1.1.4 | 2023-12-13 | [33448](https://github.com/airbytehq/airbyte/pull/33448) | Increase test coverage and migrate to base image |
85-
| 1.1.3 | 2023-09-23 | [30248](https://github.com/airbytehq/airbyte/pull/30248) | Add new field "type" to board stream |
86-
| 1.1.2 | 2023-08-23 | [29777](https://github.com/airbytehq/airbyte/pull/29777) | Add retry for `502` error |
87-
| 1.1.1 | 2023-08-15 | [29429](https://github.com/airbytehq/airbyte/pull/29429) | Ignore `null` records in response |
88-
| 1.1.0 | 2023-07-05 | [27944](https://github.com/airbytehq/airbyte/pull/27944) | Add incremental sync for Items and Boards streams |
89-
| 1.0.0 | 2023-06-20 | [27410](https://github.com/airbytehq/airbyte/pull/27410) | Add new streams: Tags, Workspaces. Add new fields for existing streams. |
90-
| 0.2.6 | 2023-06-12 | [27244](https://github.com/airbytehq/airbyte/pull/27244) | Added http error handling for `403` and `500` HTTP errors |
91-
| 0.2.5 | 2023-05-22 | [225881](https://github.com/airbytehq/airbyte/pull/25881) | Fix pagination for the items stream |
92-
| 0.2.4 | 2023-04-26 | [25277](https://github.com/airbytehq/airbyte/pull/25277) | Increase row limit to 100 |
93-
| 0.2.3 | 2023-03-06 | [23231](https://github.com/airbytehq/airbyte/pull/23231) | Publish using low-code CDK Beta version |
94-
| 0.2.2 | 2023-01-04 | [20996](https://github.com/airbytehq/airbyte/pull/20996) | Fix json schema loader |
95-
| 0.2.1 | 2022-12-15 | [20533](https://github.com/airbytehq/airbyte/pull/20533) | Bump CDK version |
96-
| 0.2.0 | 2022-12-13 | [19586](https://github.com/airbytehq/airbyte/pull/19586) | Migrate to low-code |
97-
| 0.1.4 | 2022-06-06 | [14443](https://github.com/airbytehq/airbyte/pull/14443) | Increase retry_factor for Items stream |
98-
| 0.1.3 | 2021-12-23 | [8172](https://github.com/airbytehq/airbyte/pull/8172) | Add oauth2.0 support |
99-
| 0.1.2 | 2021-12-07 | [8429](https://github.com/airbytehq/airbyte/pull/8429) | Update titles and descriptions |
100-
| 0.1.1 | 2021-11-18 | [8016](https://github.com/airbytehq/airbyte/pull/8016) | 🐛 Source Monday: fix pagination and schema bug |
101-
| 0.1.0 | 2021-11-07 | [7168](https://github.com/airbytehq/airbyte/pull/7168) | 🎉 New Source: Monday |
75+
| Version | Date | Pull Request | Subject |
76+
|:--------|:-----------|:----------------------------------------------------------|:--------------------------------------------------------------------------------------------------|
77+
| 2.1.2 | 2024-04-30 | [37722](https://github.com/airbytehq/airbyte/pull/37722) | Fetch `display_value` field for column values of `Mirror`, `Dependency` and `Connect Board` types |
78+
| 2.1.1 | 2024-04-05 | [36717](https://github.com/airbytehq/airbyte/pull/36717) | Add handling of complexityBudgetExhausted error. |
79+
| 2.1.0 | 2024-04-03 | [36746](https://github.com/airbytehq/airbyte/pull/36746) | Pin airbyte-cdk version to `^0` |
80+
| 2.0.4 | 2024-02-28 | [35696](https://github.com/airbytehq/airbyte/pull/35696) | Fix extraction for `null` value in stream `Activity logs` |
81+
| 2.0.3 | 2024-02-21 | [35506](https://github.com/airbytehq/airbyte/pull/35506) | Support for column values of the mirror type for the `Items` stream. |
82+
| 2.0.2 | 2024-02-12 | [35146](https://github.com/airbytehq/airbyte/pull/35146) | Manage dependencies with Poetry. |
83+
| 2.0.1 | 2024-02-08 | [35016](https://github.com/airbytehq/airbyte/pull/35016) | Migrated to the latest airbyte cdk |
84+
| 2.0.0 | 2024-01-12 | [34108](https://github.com/airbytehq/airbyte/pull/34108) | Migrated to the latest API version: 2024-01 |
85+
| 1.1.4 | 2023-12-13 | [33448](https://github.com/airbytehq/airbyte/pull/33448) | Increase test coverage and migrate to base image |
86+
| 1.1.3 | 2023-09-23 | [30248](https://github.com/airbytehq/airbyte/pull/30248) | Add new field "type" to board stream |
87+
| 1.1.2 | 2023-08-23 | [29777](https://github.com/airbytehq/airbyte/pull/29777) | Add retry for `502` error |
88+
| 1.1.1 | 2023-08-15 | [29429](https://github.com/airbytehq/airbyte/pull/29429) | Ignore `null` records in response |
89+
| 1.1.0 | 2023-07-05 | [27944](https://github.com/airbytehq/airbyte/pull/27944) | Add incremental sync for Items and Boards streams |
90+
| 1.0.0 | 2023-06-20 | [27410](https://github.com/airbytehq/airbyte/pull/27410) | Add new streams: Tags, Workspaces. Add new fields for existing streams. |
91+
| 0.2.6 | 2023-06-12 | [27244](https://github.com/airbytehq/airbyte/pull/27244) | Added http error handling for `403` and `500` HTTP errors |
92+
| 0.2.5 | 2023-05-22 | [225881](https://github.com/airbytehq/airbyte/pull/25881) | Fix pagination for the items stream |
93+
| 0.2.4 | 2023-04-26 | [25277](https://github.com/airbytehq/airbyte/pull/25277) | Increase row limit to 100 |
94+
| 0.2.3 | 2023-03-06 | [23231](https://github.com/airbytehq/airbyte/pull/23231) | Publish using low-code CDK Beta version |
95+
| 0.2.2 | 2023-01-04 | [20996](https://github.com/airbytehq/airbyte/pull/20996) | Fix json schema loader |
96+
| 0.2.1 | 2022-12-15 | [20533](https://github.com/airbytehq/airbyte/pull/20533) | Bump CDK version |
97+
| 0.2.0 | 2022-12-13 | [19586](https://github.com/airbytehq/airbyte/pull/19586) | Migrate to low-code |
98+
| 0.1.4 | 2022-06-06 | [14443](https://github.com/airbytehq/airbyte/pull/14443) | Increase retry_factor for Items stream |
99+
| 0.1.3 | 2021-12-23 | [8172](https://github.com/airbytehq/airbyte/pull/8172) | Add oauth2.0 support |
100+
| 0.1.2 | 2021-12-07 | [8429](https://github.com/airbytehq/airbyte/pull/8429) | Update titles and descriptions |
101+
| 0.1.1 | 2021-11-18 | [8016](https://github.com/airbytehq/airbyte/pull/8016) | 🐛 Source Monday: fix pagination and schema bug |
102+
| 0.1.0 | 2021-11-07 | [7168](https://github.com/airbytehq/airbyte/pull/7168) | 🎉 New Source: Monday |

0 commit comments

Comments
 (0)