Skip to content

[WEB-6816]chore: added support for pql filters#39

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

[WEB-6816]chore: added support for pql filters#39
sangeethailango wants to merge 4 commits intomainfrom
chore-pql-support

Conversation

@sangeethailango
Copy link
Copy Markdown
Member

@sangeethailango sangeethailango commented Apr 8, 2026

This pull request adds support for filtering work items using PQL (Project Query Language) in the work items API. The main changes introduce a new pql parameter to the work item listing functionality and include a corresponding unit test to ensure the filter works as expected.

API Enhancements:

  • Added an optional pql parameter to the ListWorkItemsParams interface in src/models/WorkItem.ts, enabling clients to filter work items using PQL queries.

Testing Improvements:

  • Added a unit test in work-items.test.ts to verify that the pql filter returns only work items matching the specified criteria.

Summary by CodeRabbit

  • New Features

    • Added an optional query-based filter (PQL) when listing work items to enable more granular, query-driven results.
  • Tests

    • Added a unit test verifying that listing with the PQL filter returns only matching work items and that created items can be filtered and cleaned up.

@sangeethailango sangeethailango requested a review from Copilot April 8, 2026 12:20
@makeplane
Copy link
Copy Markdown

makeplane bot commented Apr 8, 2026

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

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 SDK support for filtering work item listings via PQL by extending the list params type and introducing a unit test to validate the behavior.

Changes:

  • Added optional pql to ListWorkItemsParams for workItems.list(...) query filtering.
  • Added a unit test that exercises listing work items with a PQL filter.

Reviewed changes

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

File Description
src/models/WorkItem.ts Extends list params typing to include pql for PQL-based filtering.
tests/unit/work-items/work-items.test.ts Adds a test case for pql filtering when listing work items.

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

Comment on lines +86 to +91
const allWorkItems = await client.workItems.list(workspaceSlug, projectId);
const priority = allWorkItems.results[0]?.priority ?? "none";

const filtered = await client.workItems.list(workspaceSlug, projectId, {
pql: `priority IN ("${priority}")`,
});
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

This test can produce false positives: if the first listed work item has no priority (or a value not supported by PQL), the fallback to "none" can yield an empty filtered result set, and the assertions still pass because the loop doesn’t run. Consider making the test deterministic by setting a known priority on the created workItem (or selecting a work item with a defined priority) and building the PQL from that known value.

Copilot uses AI. Check for mistakes.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Warning

Rate limit exceeded

@sangeethailango has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 49 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 11 minutes and 49 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: f29f7b89-59d2-4984-93d3-15259beb9d45

📥 Commits

Reviewing files that changed from the base of the PR and between efa06f2 and e0e05aa.

📒 Files selected for processing (1)
  • tests/unit/work-items/work-items.test.ts
📝 Walkthrough

Walkthrough

Adds an optional pql?: string to ListWorkItemsParams in the WorkItem model and introduces a unit test that verifies listing work items with a PQL filter (priority-based).

Changes

Cohort / File(s) Summary
Model Enhancement
src/models/WorkItem.ts
Added optional pql?: string to the exported ListWorkItemsParams interface to allow PQL-based filtering when listing work items.
Test Coverage
tests/unit/work-items/work-items.test.ts
New unit test that creates a high-priority work item, calls client.workItems.list with pql: 'priority IN ("high")', asserts returned items match priority, and cleans up the created item.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nibble through code, a tiny tweak so neat,
A PQL whisper helps the results all meet,
High-priority hops into my little test,
Filtered and found — the list does its best! ✨

🚥 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 summarizes the main change: adding PQL filter support to the work items API, which is reflected in both the interface extension and the new test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

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 `@src/models/WorkItem.ts`:
- Around line 51-52: The file has Prettier formatting violations around the
expanded mapped type for WorkItem (the line referencing WorkItemExpandableFields
and the mapped type for Expanded/WorkItem); run your formatter (prettier) to
reformat src/models/WorkItem.ts and fix spacing/semicolons so the mapped type
line for [K in Expanded]: K extends keyof WorkItemExpandableFields ?
WorkItemExpandableFields[K] : never; matches project style, then commit the
formatted file.

In `@tests/unit/work-items/work-items.test.ts`:
- Around line 93-97: The test currently can pass vacuously when filtered.results
is empty; after verifying filtered and that filtered.results is an array, add an
assertion that filtered.results.length is greater than 0 to ensure at least one
item is returned, then continue the existing loop asserting each wi.priority
equals the expected priority (references: filtered, filtered.results, priority).
🪄 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: c665f4e4-0733-4ab0-9de4-41538a4a4f3b

📥 Commits

Reviewing files that changed from the base of the PR and between ebeb2f8 and e9af1db.

📒 Files selected for processing (2)
  • src/models/WorkItem.ts
  • tests/unit/work-items/work-items.test.ts

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/work-items/work-items.test.ts (1)

85-105: Ensure created test data is always cleaned up (Line 104).

If any assertion fails before Line 104, pqlWorkItem is not deleted. Wrap assertions in try/finally so cleanup always runs.

Proposed refactor
   it("should list work items with pql filter", async () => {
     const name = randomizeName();
     const pqlWorkItem = await client.workItems.create(workspaceSlug, projectId, {
       name,
       priority: "high",
     });

-    const filtered = await client.workItems.list(workspaceSlug, projectId, {
-      pql: 'priority IN ("high")',
-    });
-
-    expect(filtered).toBeDefined();
-    expect(Array.isArray(filtered.results)).toBe(true);
-    expect(filtered.results.length).toBeGreaterThan(0);
-    expect(filtered.results.find((wi) => wi.id === pqlWorkItem.id)).toBeDefined();
-    for (const wi of filtered.results) {
-      expect(wi.priority).toBe("high");
-    }
-
-    await client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!);
+    try {
+      const filtered = await client.workItems.list(workspaceSlug, projectId, {
+        pql: 'priority IN ("high")',
+      });
+
+      expect(filtered).toBeDefined();
+      expect(Array.isArray(filtered.results)).toBe(true);
+      expect(filtered.results.length).toBeGreaterThan(0);
+      expect(filtered.results.find((wi) => wi.id === pqlWorkItem.id)).toBeDefined();
+      for (const wi of filtered.results) {
+        expect(wi.priority).toBe("high");
+      }
+    } finally {
+      await client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!);
+    }
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/work-items/work-items.test.ts` around lines 85 - 105, The test
"should list work items with pql filter" creates pqlWorkItem via
client.workItems.create but deletes it only at the end, so if an assertion
throws the created item may leak; wrap the assertions (the body between creation
and deletion) in a try/finally and perform
client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!) in the
finally block, guarding the delete with a check that pqlWorkItem and
pqlWorkItem.id are defined to avoid runtime errors; this ensures cleanup even if
any expect calls fail.
🤖 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/work-items/work-items.test.ts`:
- Around line 85-105: The test "should list work items with pql filter" creates
pqlWorkItem via client.workItems.create but deletes it only at the end, so if an
assertion throws the created item may leak; wrap the assertions (the body
between creation and deletion) in a try/finally and perform
client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!) in the
finally block, guarding the delete with a check that pqlWorkItem and
pqlWorkItem.id are defined to avoid runtime errors; this ensures cleanup even if
any expect calls fail.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6900ada8-f485-43a9-8052-4e6f7765fadd

📥 Commits

Reviewing files that changed from the base of the PR and between e9af1db and efa06f2.

📒 Files selected for processing (2)
  • src/models/WorkItem.ts
  • tests/unit/work-items/work-items.test.ts
✅ Files skipped from review due to trivial changes (1)
  • src/models/WorkItem.ts

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>
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