Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop paging on empty response feature #121

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

kacurez
Copy link
Member

@kacurez kacurez commented Aug 22, 2024

https://keboola.atlassian.net/browse/ST-2131
Stop pagination if response contains empty data but still returns next page url.
This only works if query has enabled "stop-on-empty-response": true.
queries example with stop-on-empty-response enabled

    "queries": [
      {
        "id": 96947,
        "type": "async-insights-query",
        "name": "test",
        "run-by-id": false,
        "query": {
          "stop-on-empty-response": true,
          "parameters": "fields=ad_id,ad_name,impressions,reach,clicks,spend&level=ad&action_breakdowns=action_type&date_preset=last_month&time_increment=1",
          "ids": "",
          "limit": "25"
        }
      }
    ]

(is (nil? (sut/get-next-page-url response false false))))

(let [response {:paging {:next "someurl"} :data []}]
(is (nil? (sut/get-next-page-url response false true))))
Copy link
Member Author

@kacurez kacurez Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case 1 - if stop-on-empty-response is enabled and data in the reponse is empty (mocked as :data []) then return nil, and pagination will consequently stop

(is (nil? (sut/get-next-page-url response false true))))

(let [response {:paging {:next "someurl"} :data [{:some "data"}]}]
(is (= "someurl" (sut/get-next-page-url response false true))))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case 2 - if stop-on-empty-response is enabled and data in the reponse is not empty (mocked as :data [{:some "data"}]}) then return someurl, and pagination will continue.

@kacurez kacurez requested a review from eddycek August 22, 2024 12:36
Copy link
Member

@eddycek eddycek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kód neumím 100% validovat, ale rozumím problému a vypadá to oka

@kacurez kacurez merged commit e974cf0 into master Aug 22, 2024
8 checks passed
@kacurez kacurez deleted the kacurez-stop-paging-on-empty-response-ST-2131 branch August 22, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants