Skip to content

[WEB-6815] chore: added support for pql #27

Open
sangeethailango wants to merge 6 commits intomainfrom
chore-pql-support
Open

[WEB-6815] chore: added support for pql #27
sangeethailango wants to merge 6 commits intomainfrom
chore-pql-support

Conversation

@sangeethailango
Copy link
Copy Markdown
Member

@sangeethailango sangeethailango commented Apr 7, 2026

Description

PQL support for work items.

Type of Change

  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)

Summary by CodeRabbit

  • New Features

    • List endpoints now accept an optional "pql" query parameter to filter work item lists using custom criteria (e.g., priority-based searches).
  • Tests

    • Added unit tests validating that list endpoints apply the new "pql" filter and return expected filtered results, including presence/absence checks for matching items.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Warning

Rate limit exceeded

@sangeethailango has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 46 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 23 minutes and 46 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4297d88-9d18-49cc-8c71-339e975be58a

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4f6e2 and 7d757b5.

📒 Files selected for processing (1)
  • tests/unit/test_work_items.py
📝 Walkthrough

Walkthrough

Added an optional pql: str | None field to WorkItemQueryParams in plane/models/query_params.py to accept a PQL filter when listing work items. A unit test was added to verify listing with a pql filter that selects by priority.

Changes

Cohort / File(s) Summary
Query Parameters Model
plane/models/query_params.py
Added optional pql: str | None field to WorkItemQueryParams; model config and other fields/validation unchanged.
Tests — Work Items
tests/unit/test_work_items.py
Imported WorkItemQueryParams; added test_list_work_items_with_pql_filter which creates two work items (high/low priority), lists with WorkItemQueryParams(pql='priority IN ("high")'), asserts high-priority is present and low-priority is absent, then cleans up by deleting both items. Also minor formatting adjustments to signatures/whitespace.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble on filters with a twitch and a hop,
A tiny pql lets the high-priority pop.
I sift through the list with a jubilant bound,
Finding the gems that were waiting to be found.
Hooray for searches — I hop back, carrot-crowned! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for PQL (a query parameter) to the work items module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore-pql-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@makeplane
Copy link
Copy Markdown

makeplane bot commented Apr 7, 2026

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

@sangeethailango sangeethailango marked this pull request as ready for review April 7, 2026 10:38
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
plane/models/query_params.py (2)

51-62: Consider updating the docstring to include pql.

The docstring documents inherited parameters from PaginatedQueryParams but doesn't mention the newly added pql parameter that's now inherited from BaseQueryParams.

📝 Suggested docstring update
 class WorkItemQueryParams(PaginatedQueryParams):
     """Query parameters for work item list endpoints.

     Inherits all documented query parameters from PaginatedQueryParams:
     - cursor: Pagination cursor
     - expand: Comma-separated fields to expand
     - external_id: External system identifier
     - external_source: External system source name
     - fields: Comma-separated fields to include
     - order_by: Field to order by (prefix with '-' for descending)
     - per_page: Number of results per page (1-100)
+    - pql: PQL filter expression
     """
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plane/models/query_params.py` around lines 51 - 62, Update the
WorkItemQueryParams docstring to list the inherited pql parameter (from
BaseQueryParams) along with the other inherited fields; locate the
WorkItemQueryParams class docstring and add a bullet like "- pql: Piped query
language string to filter results" (or similar brief description) so the
documentation reflects that pql is available via inheritance from
BaseQueryParams/PaginatedQueryParams.

31-31: Improve the field description wording.

The description "Field to apply PQL filters" is grammatically awkward—"Field" doesn't work as the subject here. Consider rewording for clarity.

📝 Suggested description improvement
-    pql: str | None = Field(None, description="Field to apply PQL filters")
+    pql: str | None = Field(None, description="PQL filter expression")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plane/models/query_params.py` at line 31, Update the Field description for
the pql attribute on the QueryParams model: replace the awkward "Field to apply
PQL filters" with a clearer phrase such as "PQL query string used to filter
results" (or similar), so the pql: str | None = Field(..., description="...")
reads as a descriptive noun phrase explaining that this value is a PQL
expression used to filter query results.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@plane/models/query_params.py`:
- Around line 51-62: Update the WorkItemQueryParams docstring to list the
inherited pql parameter (from BaseQueryParams) along with the other inherited
fields; locate the WorkItemQueryParams class docstring and add a bullet like "-
pql: Piped query language string to filter results" (or similar brief
description) so the documentation reflects that pql is available via inheritance
from BaseQueryParams/PaginatedQueryParams.
- Line 31: Update the Field description for the pql attribute on the QueryParams
model: replace the awkward "Field to apply PQL filters" with a clearer phrase
such as "PQL query string used to filter results" (or similar), so the pql: str
| None = Field(..., description="...") reads as a descriptive noun phrase
explaining that this value is a PQL expression used to filter query results.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a8f8b61c-7077-4fa9-a3e1-7422aa92fe2f

📥 Commits

Reviewing files that changed from the base of the PR and between 72ecc72 and 3902c73.

📒 Files selected for processing (1)
  • plane/models/query_params.py

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/unit/test_work_items.py (1)

34-45: Consider asserting non-empty results to prevent vacuous test passes.

If the API returns an empty list (due to no matching items or a PQL bug), the for loop executes zero iterations and the priority assertion is vacuously satisfied. The test would pass even if the PQL filter is broken.

Consider either:

  1. Adding assert len(response.results) > 0 if the test environment is expected to have high-priority items
  2. Or creating a high-priority work item as a fixture before testing the filter
💡 Optional fix to guard against empty results
     def test_list_work_items_with_pql_filter(
         self, client: PlaneClient, workspace_slug: str, project: Project
     ) -> None:
         """Test listing work items with a PQL filter."""
         params = WorkItemQueryParams(pql='priority IN ("high")')
         response = client.work_items.list(workspace_slug, project.id, params=params)
         assert response is not None
         assert hasattr(response, "results")
         assert isinstance(response.results, list)
+        # Ensure we have results to validate the filter actually works
+        assert len(response.results) > 0, "No high-priority work items found to validate filter"
         for item in response.results:
             assert item.priority == "high"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/test_work_items.py` around lines 34 - 45, The test
test_list_work_items_with_pql_filter currently can pass vacuously when
response.results is empty; update the test to assert non-empty results or ensure
a high-priority item exists before querying: either add an assertion like assert
len(response.results) > 0 after obtaining response.results, or create a
high-priority work item via the client (using client.work_items.create or your
fixture helper) prior to calling WorkItemQueryParams and client.work_items.list
so the PQL filter actually has matching data to validate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/unit/test_work_items.py`:
- Around line 34-45: The test test_list_work_items_with_pql_filter currently can
pass vacuously when response.results is empty; update the test to assert
non-empty results or ensure a high-priority item exists before querying: either
add an assertion like assert len(response.results) > 0 after obtaining
response.results, or create a high-priority work item via the client (using
client.work_items.create or your fixture helper) prior to calling
WorkItemQueryParams and client.work_items.list so the PQL filter actually has
matching data to validate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa59d9df-b63e-4e8d-b9b3-8665e73814ec

📥 Commits

Reviewing files that changed from the base of the PR and between 3902c73 and ba04ab2.

📒 Files selected for processing (1)
  • tests/unit/test_work_items.py

Copy link
Copy Markdown

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

Adds client-side support for sending PQL (Plane Query Language) filters when listing work items, along with a smoke test to validate filtered list behavior.

Changes:

  • Extended shared query param models to include an optional pql query parameter.
  • Added a work items list test that uses pql to filter by priority.

Reviewed changes

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

File Description
plane/models/query_params.py Introduces pql on the base query params model so it can be serialized into request query strings.
tests/unit/test_work_items.py Adds a smoke test covering list filtering via pql and updates imports accordingly.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/test_work_items.py`:
- Around line 34-54: The test_list_work_items_with_pql_filter test is weak
because it can pass if the pql is ignored; update it to create a second, clearly
non-matching work item (e.g., priority="low" or name that doesn't match the PQL)
using client.work_items.create, then call client.work_items.list with
WorkItemQueryParams(pql='priority IN ("high")') and assert the created
high-priority item's id is present and the non-matching item's id is not present
in response.results; ensure you still validate response is not None, has
.results, and results is a list before checking IDs.
- Around line 38-54: The test creates a work item (created_item via
client.work_items.create) but never deletes it; wrap the creation and assertions
in a try/finally (or add teardown) and call the work-items deletion API (e.g.,
client.work_items.delete(workspace_slug, project.id, created_item.id) or the
appropriate remove method) in the finally block to ensure the created_item is
removed regardless of test outcome; ensure created_item is defined before
calling delete (guard against create failures) and handle/ignore NotFound errors
if delete races with other cleanup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1bbf77db-8dd3-4a09-82b4-2c7a1c54c029

📥 Commits

Reviewing files that changed from the base of the PR and between ba04ab2 and 6bef0f2.

📒 Files selected for processing (2)
  • plane/models/query_params.py
  • tests/unit/test_work_items.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • plane/models/query_params.py

Copy link
Copy Markdown

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

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


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

Copy link
Copy Markdown

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

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


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

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

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


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

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