Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plane/api/work_items/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ def count_workspace(
ISO-date strings for ``target_date`` / ``start_date``. ``"None"`` is
used for work items with no value in that dimension.

When only ``group_by`` is supplied each ``grouped_counts`` entry has
shape ``{"count": N}``. When ``sub_group_by`` is also supplied the
shape becomes ``{"total_count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``.
Each ``grouped_counts`` entry always has ``count``. When
``sub_group_by`` is also supplied it additionally carries
``sub_grouped_counts``, a dict mapping sub-group keys to ``{"count": N}``.

Args:
workspace_slug: The workspace slug identifier
Expand Down Expand Up @@ -323,7 +323,7 @@ def count_workspace(
),
)
for group, entry in result.grouped_counts.items():
print(f"{group}: {entry.total_count} total")
print(f"{group}: {entry.count} total")
for sub_group, sub_entry in (entry.sub_grouped_counts or {}).items():
print(f" {sub_group}: {sub_entry.count}")

Expand Down
12 changes: 5 additions & 7 deletions plane/models/work_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,13 @@ class WorkItemGroupCountEntry(BaseModel):

* **Flat** (``group_by`` only): ``{"count": N}``
* **Nested** (``group_by`` + ``sub_group_by``):
``{"total_count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``
``{"count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``
"""

model_config = ConfigDict(extra="allow", populate_by_name=True)

# flat grouped shape (group_by only)
count: int | None = None
# sub-grouped shape (group_by + sub_group_by)
total_count: int | None = None
count: int

sub_grouped_counts: dict[str, WorkItemSubGroupCountEntry] | None = None


Expand All @@ -641,7 +639,7 @@ class WorkItemGroupedCountResponse(BaseModel):
"grouped_counts": {"urgent": {"count": 3}, "None": {"count": 6}}
}

**With** ``group_by`` and ``sub_group_by`` — values carry ``total_count``
**With** ``group_by`` and ``sub_group_by`` — values carry ``count``
and a nested ``sub_grouped_counts`` dict::

{
Expand All @@ -650,7 +648,7 @@ class WorkItemGroupedCountResponse(BaseModel):
"total_count": 42,
"grouped_counts": {
"urgent": {
"total_count": 3,
"count": 3,
"sub_grouped_counts": {
"949645da-a9dd-4a90-94b0-6c8fa16245ee": {"count": 2},
"94d35657-a48c-44fd-bed8-87d895386ba4": {"count": 1}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plane-sdk"
version = "0.2.16"
version = "0.2.17"
description = "Python SDK for Plane API"
readme = "README.md"
requires-python = ">=3.10"
Expand Down