Skip to content

[AJDA-2500] Add PaginationHelper, JobStatus enum, remove executeWorkspaceQuery#476

Merged
ondrajodas merged 2 commits intomainfrom
ondra/AJDA-2500
Mar 26, 2026
Merged

[AJDA-2500] Add PaginationHelper, JobStatus enum, remove executeWorkspaceQuery#476
ondrajodas merged 2 commits intomainfrom
ondra/AJDA-2500

Conversation

@ondrajodas
Copy link
Contributor

@ondrajodas ondrajodas commented Mar 24, 2026

Summary

  • Add optional $pageSize and $offset parameters to Client::getJobResults()
  • Add new PaginationHelper class to fetch all result pages for completed statements
  • Add JobStatus string-backed enum replacing hardcoded status strings
  • Remove executeWorkspaceQuery() method and WorkspaceQueryResponse class (breaking changes)

Breaking changes

  • getStatus() on Statement, JobStatusResponse, JobResultsResponse now returns JobStatus enum instead of string
  • Client::executeWorkspaceQuery() removed — use submitQueryJob() + waitForJobCompletion() + PaginationHelper::getAllResults() instead
  • Response\WorkspaceQueryResponse class removed

@linear
Copy link

linear bot commented Mar 24, 2026

@ondrajodas
Copy link
Contributor Author

ondrajodas commented Mar 24, 2026

# Release Notes
- New `PaginationHelper` class for fetching all pages of query results
- New `JobStatus` string-backed enum (`Completed`, `Failed`, `Canceled`, `Running`, `Waiting`, `Processing`, `NotExecuted`, `Enqueued`)
- `getStatus()` on `Statement`, `JobStatusResponse`, `JobResultsResponse` now returns `JobStatus` enum (breaking change)
- `Client::executeWorkspaceQuery()` removed (breaking change)
- `Response\WorkspaceQueryResponse` class removed (breaking change)
- `Client::getJobResults()` now accepts optional `$pageSize` and `$offset` query parameters

# Plans for Customer Communication
Consumers of this library need to update: replace `getStatus() === 'completed'` with `getStatus() === JobStatus::Completed` and replace calls to `executeWorkspaceQuery()` with `submitQueryJob()` + `waitForJobCompletion()` + `PaginationHelper::getAllResults()`.

# Impact Analysis
Breaking changes to `query-service-api-client`. All consumers must update their code. No infrastructure changes required.

# Change Type
Feature + breaking changes (major version bump required)

# Justification
Pagination support for large result sets; type-safe status handling via enum; cleaner API surface by removing the monolithic executeWorkspaceQuery.

# Deployment Plan
Bump major version of `query-service-api-client`. Update all internal consumers before release.

# Rollback Plan
Pin to previous major version of the library.

# Post-Release Support Plan
Monitor for ValueError exceptions from unknown JobStatus values if the API introduces new statuses.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Query Service API PHP client to support pagination when fetching job results by introducing optional query parameters and plumbing them through higher-level query execution.

Changes:

  • Added optional pageSize and offset parameters to Client::getJobResults() and appended them as Guzzle query parameters when provided.
  • Extended the internal sendRequest() helper to accept optional query parameters passed through to Guzzle.
  • Added PHPUnit coverage for getJobResults() query parameter behavior and for executeWorkspaceQuery() forwarding pagination.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
libs/query-service-api-client/src/Client.php Adds optional pagination query params to job results fetching and extends request helper to support query parameters.
libs/query-service-api-client/tests/Phpunit/ClientTest.php Adds tests asserting correct query string construction and pagination forwarding behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 195 to 202
int $maxWaitSeconds = self::DEFAULT_MAX_WAIT_SECONDS,
int $maxPollWaitMs = self::DEFAULT_MAX_POLL_WAIT_MS,
?int $pageSize = null,
): WorkspaceQueryResponse {
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

executeWorkspaceQuery only added $pageSize but the PR description says both pageSize and offset should be supported and propagated. Consider adding an optional ?int $offset = null parameter here as well (after $pageSize) so callers can control the results offset when using executeWorkspaceQuery.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intentionally not added — the Linear issue (AJDA-2500) specifies only $pageSize for executeWorkspaceQuery. $offset is available directly on getJobResults for callers who need fine-grained control.

Copy link
Member

Choose a reason for hiding this comment

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

Já tomu teda ale taky moc nerozumím jak to pak bude stránkovat :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no todle nebude stránkovat no... já nevím jestli tu logiku stránkování úplně strkat sem... mě se upřímně celá tahle executeWorkspaceQuery metoda moc nelíbí :D

Copy link
Member

Choose a reason for hiding this comment

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

No, ale o to šlo, aby tohle stránkovalo ne? podle toho k čemu to směřuje https://linear.app/keboola/issue/AJDA-2501/editor-service-sqldataprovider-paginate-executequery-to-fetch-all-job

no jestli ju uděláš líp, tak hurá do toho, je to úzký hrdlo

@ondrajodas ondrajodas marked this pull request as ready for review March 24, 2026 10:15
@ondrajodas ondrajodas requested a review from odinuv March 24, 2026 10:30
$queryParams['offset'] = $offset;
}
return JobResultsResponse::fromResponse(
$this->sendRequest('GET', $url, null, $queryParams !== [] ? $queryParams : null),
Copy link
Member

Choose a reason for hiding this comment

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

tady bych si to podminku asi odpustil - resp. nechal sendRequest at si to vyresi

Comment on lines 195 to 202
int $maxWaitSeconds = self::DEFAULT_MAX_WAIT_SECONDS,
int $maxPollWaitMs = self::DEFAULT_MAX_POLL_WAIT_MS,
?int $pageSize = null,
): WorkspaceQueryResponse {
Copy link
Member

Choose a reason for hiding this comment

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

Já tomu teda ale taky moc nerozumím jak to pak bude stránkovat :)

@ondrajodas ondrajodas changed the title [AJDA-2500] Add optional pageSize and offset parameters to getJobResults [AJDA-2500] Add PaginationHelper, JobStatus enum, remove executeWorkspaceQuery Mar 24, 2026
@ondrajodas
Copy link
Contributor Author

protikus k tomu - https://github.com/keboola/editor-service/pull/85

@ondrajodas ondrajodas requested a review from odinuv March 25, 2026 10:25
Copy link
Member

@odinuv odinuv left a comment

Choose a reason for hiding this comment

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

jo, asi dobrý

@ondrajodas ondrajodas merged commit 24e1fd4 into main Mar 26, 2026
6 checks passed
@ondrajodas ondrajodas deleted the ondra/AJDA-2500 branch March 26, 2026 11:03
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.

3 participants