[BUG]: respect granularity when limiting analytics time-series buckets

已关闭 适合新手
#333 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@Sparsh2105 已经在做这个了。

开始于 2026年10月11日。

  • #334 来自 @Sparsh2105 —— 已合并

评估

难度
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
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
  1. Run the application locally using npm run dev.
  2. Explore an organisation with sufficient issue or pull request history, such as AOSSIE-Org.
  3. Navigate to the Analytics page.
  4. Click Run Complete Analysis to populate the time-series chart.
  5. Select Monthly granularity and observe the displayed date range.
  6. Switch to Weekly granularity.
  7. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AOSSIE-Org/OrgExplorer 的其他 Issue

查看 AOSSIE-Org/OrgExplorer 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。