From c74edb732c602f396bd4ab885c9885be290b1eac Mon Sep 17 00:00:00 2001 From: lordsarcastic Date: Mon, 7 Oct 2024 18:57:25 +0100 Subject: [PATCH] Fix: Bug on params for issues --- integrations/jira/client.py | 2 -- integrations/jira/integration.py | 4 ++++ integrations/jira/main.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/integrations/jira/client.py b/integrations/jira/client.py index e5cfa16e18..8c1ef8828e 100644 --- a/integrations/jira/client.py +++ b/integrations/jira/client.py @@ -7,7 +7,6 @@ from port_ocean.context.ocean import ocean from port_ocean.utils import http_async_client - PAGE_SIZE = 50 WEBHOOK_NAME = "Port-Ocean-Events-Webhook" REQUEST_TIMEOUT = 120 @@ -102,7 +101,6 @@ async def get_all_issues( self, params: dict[str, Any] = {}, ) -> AsyncGenerator[list[dict[str, Any]], None]: - async for issues in self._make_paginated_request( f"{self.detail_base_url}/search", params=params, diff --git a/integrations/jira/integration.py b/integrations/jira/integration.py index f958fa59e7..2755b80999 100644 --- a/integrations/jira/integration.py +++ b/integrations/jira/integration.py @@ -14,6 +14,10 @@ class JiraIssueSelector(Selector): jql: str | None = Field( description="Jira Query Language (JQL) query to filter issues", ) + fields: str | None = Field( + description="Additional fields to be included in the API response", + default="*all", + ) class JiraIssueResourceConfig(ResourceConfig): diff --git a/integrations/jira/main.py b/integrations/jira/main.py index 2d079fc95f..b3e12df15c 100644 --- a/integrations/jira/main.py +++ b/integrations/jira/main.py @@ -53,8 +53,15 @@ async def on_resync_projects(kind: str) -> ASYNC_GENERATOR_RESYNC_TYPE: @ocean.on_resync(ObjectKind.ISSUE) async def on_resync_issues(kind: str) -> ASYNC_GENERATOR_RESYNC_TYPE: client = initialize_client() - config = typing.cast(JiraIssueResourceConfig, event.resource_config) - async for issues in client.get_all_issues(config): + config = typing.cast(JiraIssueResourceConfig, event.resource_config).selector + params = {} + if config.jql: + params["jql"] = config.jql + + if config.fields: + params["fields"] = config.fields + + async for issues in client.get_all_issues(params): logger.info(f"Received issue batch with {len(issues)} issues") yield issues