[BUG]: respect granularity when limiting analytics time-series buckets
维护者通常 4 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript
- 领域
- analytics
调研方向
阅读 src/services/analytics.js 和 src/services/analytics.buildTimeSeries.test.js 中现有的测试。检查 buildTimeSeries 如何处理每周和每月的 bucket,以及测试如何验证 bucket 数量和顺序。月度结果上限为 12、每周结果上限为 26,且结果仍按时间顺序排列时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Bug Description
The buildTimeSeries function in src/services/analytics.js limits its output to the last 12 buckets regardless of the selected granularity.
As a result, the Weekly view displays only approximately 12 weeks of activity (~3 months), while the Monthly view can display up to 12 months of activity. This creates inconsistent historical windows when switching between granularities.
The function already accepts a granularity parameter, but the final .slice(-12) applies the same limit to both monthly and weekly buckets.
Expected Behavior:
- Monthly granularity should retain up to 12 buckets (~12 months).
- Weekly granularity should retain up to 26 buckets (~6 months).
Actual Behavior:
Both granularities are limited to 12 buckets, causing older activity to disappear from the Weekly view.
Proposed Fix
Use a bucket limit based on the selected granularity instead of hardcoding the limit to 12:
const SLICE_COUNT = granularity === 'weekly' ? 26 : 12;
return Object.values(buckets)
.sort((a, b) => a.date.localeCompare(b.date))
.slice(-SLICE_COUNT);
This allows the Weekly view to retain up to 26 buckets while preserving the existing 12-bucket limit for the Monthly view.
Testing
Update src/services/analytics.buildTimeSeries.test.js to verify that:
- Monthly granularity returns at most 12 buckets.
- Weekly granularity returns at most 26 buckets.
- Weekly granularity can return more than 12 buckets when sufficient data is available.
- Results remain sorted chronologically.
Scope
- Implementation:
src/services/analytics.js - Tests:
src/services/analytics.buildTimeSeries.test.js - No UI, layout, or API changes are required.
Steps to Reproduce
- Run the application locally using
npm run dev. - Explore an organisation with sufficient issue or pull request history, such as
AOSSIE-Org. - Navigate to the Analytics page.
- Click Run Complete Analysis to populate the time-series chart.
- Select Monthly granularity and observe the displayed date range.
- Switch to Weekly granularity.
- Observe that the chart displays at most 12 weekly buckets, even when older activity is available.
The issue can also be reproduced by passing more than 12 distinct weekly buckets to buildTimeSeries in src/services/analytics.js.
Logs and Screenshots
No error logs are expected because this is a data truncation issue rather than a runtime error.
A screenshot comparing the Monthly and Weekly analytics views would help demonstrate the inconsistent historical windows.
Relevant implementation: src/services/analytics.js, where the returned buckets are limited using .slice(-12).
Relevant tests: src/services/analytics.buildTimeSeries.test.js.
Environment Details
- OS: Ubuntu 26 LTS
- Browser: Brave (Chromium-based)
- Runtime: Node.js 22.22.1
- Project: AOSSIE-Org/OrgExplorer
- Setup: Local development environment using
npm run dev - Additional context: The issue concerns the time-series bucket limit in
src/services/analytics.js.
Impact
Medium - Feature works but has issues
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
- 主要语言
- JavaScript
- 星标
- 48
- 派生
- 169
- 平均合并
- 4 天 13 小时
- 30 天内合并 PR
- 25
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AOSSIE-Org/OrgExplorer 的其他 Issue
-
[BUG]: `fetchWithCache` crashes with `SyntaxError: Unexpected end of JSON input` when encountering empty repositories (HTTP 204 No Content)可能已有人在做 @Devnil434 于 6 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
AOSSIE-Org/OrgExplorer#433 · 1 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Table sort headers can't be used from the keyboard and don't announce sort order可能已有人在做 @Simran-Sobhani 于 7 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 78/100
AOSSIE-Org/OrgExplorer#419 · 2 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Connect PAT modal saves invalid GitHub tokens without validation可能重新可做 @Prince-ES 于 10 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/OrgExplorer#416 · 1 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Avoid triggering Release Drafter for closed, unmerged pull requests可能已有人在做 @Praveena2809 于 7 天前认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 82/100
AOSSIE-Org/OrgExplorer#414 · 2 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Overview "Language Distribution" percentages are relative to the top-7 languages, not all repos可能已有人在做 @Rohit270406 于 12 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
AOSSIE-Org/OrgExplorer#402 · 1 条评论 ·
维护者通常 4 天内回复
查看 AOSSIE-Org/OrgExplorer 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
help wanted Idea 💡 wdio-cli
难度 2/5 1-3 小时 新手友好度 66/100
webdriverio/webdriverio#16361 · 2 条评论 ·
维护者通常 1 天内回复
-
bug new-client
难度 1/5 1-3 小时 新手友好度 88/100
NUWCDIVNPT/stig-manager#2285 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
Fei2411/DeepSeek-Bot#922 · 1 个 reaction ·