Skip to content

Commit bbe69ef

Browse files
chore: work item count api response (#52)
* fix: updated WorkItemGroupCountEntry response fields * chore: updated version
1 parent b23b595 commit bbe69ef

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

plane/api/work_items/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ def count_workspace(
284284
ISO-date strings for ``target_date`` / ``start_date``. ``"None"`` is
285285
used for work items with no value in that dimension.
286286
287-
When only ``group_by`` is supplied each ``grouped_counts`` entry has
288-
shape ``{"count": N}``. When ``sub_group_by`` is also supplied the
289-
shape becomes ``{"total_count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``.
287+
Each ``grouped_counts`` entry always has ``count``. When
288+
``sub_group_by`` is also supplied it additionally carries
289+
``sub_grouped_counts``, a dict mapping sub-group keys to ``{"count": N}``.
290290
291291
Args:
292292
workspace_slug: The workspace slug identifier
@@ -323,7 +323,7 @@ def count_workspace(
323323
),
324324
)
325325
for group, entry in result.grouped_counts.items():
326-
print(f"{group}: {entry.total_count} total")
326+
print(f"{group}: {entry.count} total")
327327
for sub_group, sub_entry in (entry.sub_grouped_counts or {}).items():
328328
print(f" {sub_group}: {sub_entry.count}")
329329

plane/models/work_items.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,15 +611,13 @@ class WorkItemGroupCountEntry(BaseModel):
611611
612612
* **Flat** (``group_by`` only): ``{"count": N}``
613613
* **Nested** (``group_by`` + ``sub_group_by``):
614-
``{"total_count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``
614+
``{"count": N, "sub_grouped_counts": {sub_key: {"count": N}}}``
615615
"""
616616

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

619-
# flat grouped shape (group_by only)
620-
count: int | None = None
621-
# sub-grouped shape (group_by + sub_group_by)
622-
total_count: int | None = None
619+
count: int
620+
623621
sub_grouped_counts: dict[str, WorkItemSubGroupCountEntry] | None = None
624622

625623

@@ -641,7 +639,7 @@ class WorkItemGroupedCountResponse(BaseModel):
641639
"grouped_counts": {"urgent": {"count": 3}, "None": {"count": 6}}
642640
}
643641
644-
**With** ``group_by`` and ``sub_group_by`` — values carry ``total_count``
642+
**With** ``group_by`` and ``sub_group_by`` — values carry ``count``
645643
and a nested ``sub_grouped_counts`` dict::
646644
647645
{
@@ -650,7 +648,7 @@ class WorkItemGroupedCountResponse(BaseModel):
650648
"total_count": 42,
651649
"grouped_counts": {
652650
"urgent": {
653-
"total_count": 3,
651+
"count": 3,
654652
"sub_grouped_counts": {
655653
"949645da-a9dd-4a90-94b0-6c8fa16245ee": {"count": 2},
656654
"94d35657-a48c-44fd-bed8-87d895386ba4": {"count": 1}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plane-sdk"
7-
version = "0.2.16"
7+
version = "0.2.17"
88
description = "Python SDK for Plane API"
99
readme = "README.md"
1010
requires-python = ">=3.10"

0 commit comments

Comments
 (0)