Skip to content

Commit 5e6df6b

Browse files
authored
fix: adjust month range in contributor heatmap to exclude current month (hiero-hackers#253)
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
1 parent 5eb4612 commit 5e6df6b

7 files changed

Lines changed: 8 additions & 4 deletions

File tree

-9.62 KB
Loading
13.2 KB
Loading
34.7 KB
Loading
1.75 KB
Loading
3.82 KB
Loading

src/hiero_analytics/analysis/contributor_heatmap.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def _month_key(value: datetime) -> str:
5353
def _recent_month_keys(months_back: int) -> list[str]:
5454
"""Return the most recent month labels, oldest first."""
5555
current_month = pd.Period(pd.Timestamp.now(tz="UTC"), freq="M")
56-
return [str(period) for period in pd.period_range(end=current_month, periods=months_back, freq="M")]
56+
# Shift back by 1 month so the range ends on the last fully completed month
57+
last_completed_month = current_month - 1
58+
59+
return [str(period) for period in pd.period_range(end=last_completed_month, periods=months_back, freq="M")]
5760

5861

5962
def _activity_action(activity_type: str) -> str | None:

tests/analysis/test_contributor_heatmap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
from datetime import UTC, datetime
6-
75
import pandas as pd
86

97
from hiero_analytics.analysis.contributor_heatmap import (
@@ -20,11 +18,14 @@
2018
def _ev(actor: str, activity_type: str, n: int, *, repo: str = "o/x") -> ContributorActivityRecord:
2119
"""Build a contributor-activity record dated to now (inside the heatmap window)."""
2220
target_type = "issue" if activity_type == "authored_issue" else "pull_request"
21+
22+
last_month_timestamp = pd.Timestamp.now(tz="UTC") - pd.DateOffset(months=1)
23+
2324
return ContributorActivityRecord(
2425
repo=repo,
2526
activity_type=activity_type,
2627
actor=actor,
27-
occurred_at=datetime.now(UTC),
28+
occurred_at=last_month_timestamp.to_pydatetime(),
2829
target_type=target_type,
2930
target_number=n,
3031
)

0 commit comments

Comments
 (0)