Skip to content

Add start and end date to weekly project statistics - #1606

Open
wroug wants to merge 5 commits into
hackclub:mainfrom
wroug:weekly-project-stats-date-range
Open

Add start and end date to weekly project statistics#1606
wroug wants to merge 5 commits into
hackclub:mainfrom
wroug:weekly-project-stats-date-range

Conversation

@wroug

@wroug wroug commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary of the problem

Creating this for #1604
Closes #1605

Describe your changes

Allow callers to get weekly project stats for custom date ranges, not only 12 weeks before today.

  • weekly_project_stats and week_ranges now accept optional start_date and end_date parameters

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds optional start and end dates to weekly project aggregation and changes weekly bucket generation.

  • Converts requested boundaries into the user's timezone before querying heartbeats
  • Generates weekly buckets across custom ranges
  • Attempts to preserve the original twelve-week default window

Confidence Score: 4/5

The PR is not yet safe to merge because the default weekly aggregation still returns inconsistent bucket counts between live and rollup-backed paths.

The attempted default-window fix is bypassed when weekly_project_stats passes its internally derived effective_start as an explicit start_date, leaving live aggregation and rollup generation at thirteen buckets while rollup reads expose twelve.

Files Needing Attention: app/services/dashboard_data/snapshots.rb

Important Files Changed

Filename Overview
app/services/dashboard_data/snapshots.rb Adds custom weekly date ranges, but the default live aggregation still bypasses the corrected twelve-bucket branch and diverges from rollup reads.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[weekly_project_stats without dates] --> B[Derive effective_start]
  B --> C[Pass effective_start as start_date]
  C --> D[week_ranges custom branch]
  D --> E[13 generated buckets]
  E --> F[Live result and rollup refresh]
  G[Rollup reader] --> H[week_ranges without dates]
  H --> I[12 generated buckets]
Loading
Prompt To Fix All With AI
### Issue 1
app/services/dashboard_data/snapshots.rb:89
**Default window still has thirteen buckets**

When `weekly_project_stats` is called without dates, it passes the derived `effective_start` as a supplied start date, causing `week_ranges` to select the custom-range branch and generate thirteen buckets. Live aggregation and rollup generation therefore cover thirteen weeks while rollup reads expose twelve, producing different weekly statistics depending on whether a valid rollup is available.

```suggestion
      ranges = week_ranges(user.timezone, start_date: start_date, end_date: end_date)
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (3): Last reviewed commit: "Merge branch 'main' into weekly-project-..." | Re-trigger Greptile

Comment thread app/services/dashboard_data/snapshots.rb Outdated
Comment thread app/services/dashboard_data/snapshots.rb
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Comment thread app/services/dashboard_data/snapshots.rb Outdated
wroug and others added 2 commits August 21, 2026 07:57
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance and include this reference: d8db30c2-ce7c-45cf-8136-12cc69191958.

@wroug

wroug commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

truly amazing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

start_date and end_date functionality to weekly_project_stats

1 participant