You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analytics Charts for Cycles and Modules Show Wrong Data — Queryset Anchored to Wrong Model #9177
When I view analytics charts filtered by a cycle or module, the daily stats chart shows incorrect data. The queryset is reassigned from Issue objects to a flat .values_list("issue_id", flat=True) queryset anchored to CycleIssue/ModuleIssue. Subsequent .values("created_at__date") calls then use the join table's created_at instead of Issue.created_at, producing wrong date groupings in the chart.
Code pattern:
cycle_issues = CycleIssue.objects.filter(...).values_list("issue_id", flat=True)
queryset = cycle_issues # queryset is now CycleIssue IDs, not Issue objects
queryset.values("created_at__date") # uses CycleIssue.created_at, not Issue.created_at
What I expect is that analytics charts for cycles and modules correctly reflect issue creation dates.
File: apps/api/plane/app/views/analytic/project_analytics.py, lines 202 and 214
Steps to reproduce
Open Analytics for a project
Filter the chart by a specific cycle or module
Observe the daily chart data doesn't match the actual issue creation dates
Could you let us know if you're on the Community Edition? Also, could you share a screen recording of the issue? We tried reproducing it on our end but couldn't, that'll help us look into it further.
Hi @sauravdas-cs — I dug into this and can answer both questions directly, plus give you something more conclusive than a screen recording for this particular bug.
Community Edition? Yes — reproduced against a clean checkout of this repo (makeplane/plane, HEAD 65f4a996), no EE/Cloud-only code involved.
Why not a screen recording: this isn't a visual glitch — the chart renders fine, it's just keyed to the wrong date under the hood. A recording would show a chart that "looks correct" unless the viewer already knows which exact date each work item was created on vs. added to the cycle, which is exactly what makes it hard to catch from the UI and easy to miss in manual testing. So instead I built a deterministic, automated reproduction that isolates the data bug directly — I think it'll be faster for you to verify than a video.
ifcycle_idisnotNone:
cycle_issues=CycleIssue.objects.filter(**self.filters["base_filters"], cycle_id=cycle_id).values_list(
"issue_id", flat=True
)
...
queryset=cycle_issues# <- still a CycleIssue queryset, not Issue
Later:
daily_stats= (
queryset.values("created_at__date") # <- CycleIssue.created_at, not Issue.created_at
.annotate(
created_count=Count("id"),
completed_count=Count("id", filter=Q(issue__state__group="completed")), # only works because queryset is still CycleIssue-shaped
)
...
)
Because queryset was never converted from the CycleIssue/ModuleIssue id projection into an actual Issue queryset, created_at__date resolves against the join table'screated_at (i.e., when the issue was added to the cycle/module) instead of the issue's own creation date. The completed_count annotation's issue__state__group traversal is itself a tell — it only makes sense if the queryset is still CycleIssue, confirming the mix-up. Same bug, same shape, in the module_id branch.
Reproduction (automated, run locally against the real stack)
Added apps/api/plane/tests/unit/views/test_project_analytics_chart.py: builds a real Workspace → Project → Cycle → Issue → CycleIssue graph in Postgres via the repo's own docker-compose-test.yml stack, with an issue created 10 days ago but added to its cycle 2 days ago, then calls work_item_completion_chart() directly.
AssertionError: expected the cycle chart to bucket the work item under the date it was
actually created (2026-07-24), but got 0 -- it is bucketing by CycleIssue.created_at
(when the issue was added to the cycle) instead of Issue.created_at
assert 0 == 1
After the fix (swap the queryset to Issue.issue_objects.filter(id__in=cycle_issues/module_issues), matching the pattern already used a few lines up in get_work_items_stats(), and correct completed_count's filter from issue__state__group to state__group since the queryset shape changes):
1 passed in 1.37s
Full unit suite afterward: 343 passed, 0 failed (no regressions).
I'll open a PR with this fix + test shortly — happy to adjust anything if you want a different approach to the queryset swap.
Activity
makeplane commentedon May 30, 2026
Synced with Plane Workspace 🔄
[GIT-229] Analytics Charts for Cycles and Modules Show Wrong Data — Queryset Anchored to Wrong Model
sauravdas-cs commentedon Jul 2, 2026
Could you let us know if you're on the Community Edition? Also, could you share a screen recording of the issue? We tried reproducing it on our end but couldn't, that'll help us look into it further.
blockgroot commentedon Aug 3, 2026
Hi @sauravdas-cs — I dug into this and can answer both questions directly, plus give you something more conclusive than a screen recording for this particular bug.
Community Edition? Yes — reproduced against a clean checkout of this repo (
makeplane/plane, HEAD65f4a996), no EE/Cloud-only code involved.Why not a screen recording: this isn't a visual glitch — the chart renders fine, it's just keyed to the wrong date under the hood. A recording would show a chart that "looks correct" unless the viewer already knows which exact date each work item was created on vs. added to the cycle, which is exactly what makes it hard to catch from the UI and easy to miss in manual testing. So instead I built a deterministic, automated reproduction that isolates the data bug directly — I think it'll be faster for you to verify than a video.
Root cause
apps/api/plane/app/views/analytic/project_analytics.py,work_item_completion_chart():Later:
Because
querysetwas never converted from theCycleIssue/ModuleIssueid projection into an actualIssuequeryset,created_at__dateresolves against the join table'screated_at(i.e., when the issue was added to the cycle/module) instead of the issue's own creation date. Thecompleted_countannotation'sissue__state__grouptraversal is itself a tell — it only makes sense if the queryset is stillCycleIssue, confirming the mix-up. Same bug, same shape, in themodule_idbranch.Reproduction (automated, run locally against the real stack)
Added
apps/api/plane/tests/unit/views/test_project_analytics_chart.py: builds a realWorkspace → Project → Cycle → Issue → CycleIssuegraph in Postgres via the repo's owndocker-compose-test.ymlstack, with an issue created 10 days ago but added to its cycle 2 days ago, then callswork_item_completion_chart()directly.Before the fix, run via:
After the fix (swap the queryset to
Issue.issue_objects.filter(id__in=cycle_issues/module_issues), matching the pattern already used a few lines up inget_work_items_stats(), and correctcompleted_count's filter fromissue__state__grouptostate__groupsince the queryset shape changes):Full unit suite afterward:
343 passed, 0 failed(no regressions).I'll open a PR with this fix + test shortly — happy to adjust anything if you want a different approach to the queryset swap.
fix(analytics): scope cycle and module chart dates
fix: port upstream Plane fixes for project assignments and analytics …