[PR #561] [MERGED] [Feature]: Statistics page - Add timeframe filtering, new widgets & fix success rate calculation #1065

Closed
opened 2026-05-06 12:34:51 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/561
Author: @aneopsy
Created: 3/1/2026
Status: Merged
Merged: 3/1/2026
Merged by: @maziggy

Base: 0.2.2b1Head: statistic-timeframe


📝 Commits (8)

  • b2603c8 fix(stats): calculate success rate from completed and failed prints only
  • 792a86f feat(stats): add new widgets, shared MetricToggle, and timeframe filtering
  • 1a7bdf2 test(stats): update StatsPage tests to match current widget structure
  • 5216beb refactor(stats): improve Color Distribution card layout and toggle
  • 168c00f feat(stats): add /archives/slim endpoint and fix dashboard bugs
  • ff3d3a8 feat(stats): add hourly heatmap for short timeframes and fix timezone bugs
  • 449dd24 Merge branch '0.2.2b1' into statistic-timeframe
  • 2b2a407 Fix num_weeks calculation to ensure at least one week

📊 Changes

18 files changed (+1870 additions, -363 deletions)

View changed files

📝 backend/app/api/routes/archives.py (+115 -13)
📝 backend/app/schemas/archive.py (+21 -0)
📝 backend/app/services/archive.py (+11 -1)
📝 backend/app/services/failure_analysis.py (+34 -14)
📝 backend/tests/integration/test_archives_api.py (+150 -0)
📝 frontend/src/__tests__/pages/StatsPage.test.tsx (+204 -14)
📝 frontend/src/api/client.ts (+38 -4)
📝 frontend/src/components/Dashboard.tsx (+8 -0)
📝 frontend/src/components/FilamentTrends.tsx (+290 -131)
frontend/src/components/MetricToggle.tsx (+39 -0)
📝 frontend/src/i18n/locales/de.ts (+42 -0)
📝 frontend/src/i18n/locales/en.ts (+42 -0)
📝 frontend/src/i18n/locales/fr.ts (+42 -0)
📝 frontend/src/i18n/locales/it.ts (+42 -0)
📝 frontend/src/i18n/locales/ja.ts (+42 -0)
📝 frontend/src/i18n/locales/pt-BR.ts (+42 -0)
📝 frontend/src/pages/StatsPage.tsx (+697 -186)
frontend/src/utils/weight.ts (+11 -0)

📄 Description

Description

  • Add timeframe selector with presets (today, this week, last 30 days, etc.) and custom date range, filtering stats, archives, and failure analysis
  • Fix success rate calculation to use completed + failed prints only, excluding queued/in-progress
  • Add new widgets: Print Time of Day (24h bar chart), Color Distribution (donut with actual filament hex colors), Records (longest print, heaviest, most expensive, busiest day, success streak)
  • Merge Color Distribution into Filament Trends card and Print Time of Day into Printer Stats card
  • Add shared MetricToggle component with exclude prop for consistent weight/prints/time toggles
  • Add backend date_from/date_to params to stats, archives, and failure analysis endpoints
  • Add i18n keys across all 6 locales (en, de, fr, ja, it, pt-BR)
  • Update StatsPage tests with enriched mock data and 16 new test cases
  • Refactor: data-driven QuickStatsWidget, findMax helper in Records, metricStyle helper in PrinterStats

Fixes #548

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Changes Made

  • Timeframe filtering — date range selector (presets + custom) on stats page, with backend date_from/date_to params on stats, archives, and failure analysis endpoints
  • Success rate fix — calculated from completed+failed only, not total prints
  • New widgets — Print Time of Day, Color Distribution, Records (personal bests)
  • Merged widgets — Color Distribution into Filament Trends card, Print Time of Day into Printer Stats card
  • Shared MetricToggle component with exclude prop
  • Dashboard improvements — localStorage size merging for new widgets, storage key bump
  • Refactored code — data-driven QuickStatsWidget, findMax helper, metricStyle helper
  • Tests updated — enriched mocks, fixed endpoint, added 16 new test cases
  • i18n — 11 new keys across 6 locales

Screenshots

image image

Testing

  • I have tested this on my local machine
  • I have tested with my printer model:

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • I have updated the documentation (if needed)
  • My changes generate no new warnings
  • I have tested my changes thoroughly

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/561 **Author:** [@aneopsy](https://github.com/aneopsy) **Created:** 3/1/2026 **Status:** ✅ Merged **Merged:** 3/1/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `0.2.2b1` ← **Head:** `statistic-timeframe` --- ### 📝 Commits (8) - [`b2603c8`](https://github.com/maziggy/bambuddy/commit/b2603c8c2d968b0a6577bd920c092758733f97b3) fix(stats): calculate success rate from completed and failed prints only - [`792a86f`](https://github.com/maziggy/bambuddy/commit/792a86f1e5474ae1f447311995b3253b817cecf5) feat(stats): add new widgets, shared MetricToggle, and timeframe filtering - [`1a7bdf2`](https://github.com/maziggy/bambuddy/commit/1a7bdf2b187aef54bb1d1099276bc6968bb747bb) test(stats): update StatsPage tests to match current widget structure - [`5216beb`](https://github.com/maziggy/bambuddy/commit/5216bebca7a7f5dbe2ec5506f11bbf2f36818e2b) refactor(stats): improve Color Distribution card layout and toggle - [`168c00f`](https://github.com/maziggy/bambuddy/commit/168c00f47d5e565de98302206df704483356ae34) feat(stats): add /archives/slim endpoint and fix dashboard bugs - [`ff3d3a8`](https://github.com/maziggy/bambuddy/commit/ff3d3a82a765fe4ca2be238acd15169584b12c91) feat(stats): add hourly heatmap for short timeframes and fix timezone bugs - [`449dd24`](https://github.com/maziggy/bambuddy/commit/449dd24f62e7eee0e5d04d6831bbf1b2b12e4056) Merge branch '0.2.2b1' into statistic-timeframe - [`2b2a407`](https://github.com/maziggy/bambuddy/commit/2b2a407648b33d19364a67dfb054c8e95855a1b8) Fix num_weeks calculation to ensure at least one week ### 📊 Changes **18 files changed** (+1870 additions, -363 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/archives.py` (+115 -13) 📝 `backend/app/schemas/archive.py` (+21 -0) 📝 `backend/app/services/archive.py` (+11 -1) 📝 `backend/app/services/failure_analysis.py` (+34 -14) 📝 `backend/tests/integration/test_archives_api.py` (+150 -0) 📝 `frontend/src/__tests__/pages/StatsPage.test.tsx` (+204 -14) 📝 `frontend/src/api/client.ts` (+38 -4) 📝 `frontend/src/components/Dashboard.tsx` (+8 -0) 📝 `frontend/src/components/FilamentTrends.tsx` (+290 -131) ➕ `frontend/src/components/MetricToggle.tsx` (+39 -0) 📝 `frontend/src/i18n/locales/de.ts` (+42 -0) 📝 `frontend/src/i18n/locales/en.ts` (+42 -0) 📝 `frontend/src/i18n/locales/fr.ts` (+42 -0) 📝 `frontend/src/i18n/locales/it.ts` (+42 -0) 📝 `frontend/src/i18n/locales/ja.ts` (+42 -0) 📝 `frontend/src/i18n/locales/pt-BR.ts` (+42 -0) 📝 `frontend/src/pages/StatsPage.tsx` (+697 -186) ➕ `frontend/src/utils/weight.ts` (+11 -0) </details> ### 📄 Description ## Description - Add timeframe selector with presets (today, this week, last 30 days, etc.) and custom date range, filtering stats, archives, and failure analysis - Fix success rate calculation to use completed + failed prints only, excluding queued/in-progress - Add new widgets: Print Time of Day (24h bar chart), Color Distribution (donut with actual filament hex colors), Records (longest print, heaviest, most expensive, busiest day, success streak) - Merge Color Distribution into Filament Trends card and Print Time of Day into Printer Stats card - Add shared MetricToggle component with exclude prop for consistent weight/prints/time toggles - Add backend date_from/date_to params to stats, archives, and failure analysis endpoints - Add i18n keys across all 6 locales (en, de, fr, ja, it, pt-BR) - Update StatsPage tests with enriched mock data and 16 new test cases - Refactor: data-driven QuickStatsWidget, findMax helper in Records, metricStyle helper in PrinterStats ## Related Issue Fixes #548 ## Type of Change <!-- Mark the relevant option with an "x" --> - [x] Bug fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test addition or update ## Changes Made - Timeframe filtering — date range selector (presets + custom) on stats page, with backend date_from/date_to params on stats, archives, and failure analysis endpoints - Success rate fix — calculated from completed+failed only, not total prints - New widgets — Print Time of Day, Color Distribution, Records (personal bests) - Merged widgets — Color Distribution into Filament Trends card, Print Time of Day into Printer Stats card - Shared MetricToggle component with exclude prop - Dashboard improvements — localStorage size merging for new widgets, storage key bump - Refactored code — data-driven QuickStatsWidget, findMax helper, metricStyle helper - Tests updated — enriched mocks, fixed endpoint, added 16 new test cases - i18n — 11 new keys across 6 locales ## Screenshots <img width="1468" height="796" alt="image" src="https://github.com/user-attachments/assets/8a4c9479-b147-4a7d-ac4e-2c86d6adfb4a" /> <img width="1440" height="939" alt="image" src="https://github.com/user-attachments/assets/a8f49606-1406-4972-b847-f65a4401ac2e" /> ## Testing - [x] I have tested this on my local machine - [x] I have tested with my printer model: <!-- e.g., X1C, P1S, A1 --> ## Checklist - [x] My code follows the project's coding style - [x] I have commented my code where necessary - [x] I have updated the documentation (if needed) - [x] My changes generate no new warnings - [x] I have tested my changes thoroughly --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:34:51 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1065
No description provided.