Updated the Obsidian docs-vault
This commit is contained in:
1 parent
72fd77ee01
commit
260282a0e2
36 files changed
+3497
-144
No files matched your search
+85
-13
@@ -1,26 +1,98 @@
|
||||
---
|
||||
title: Statistics
|
||||
tags:
|
||||
- feature
|
||||
- statistics
|
||||
- dashboard
|
||||
- charts
|
||||
---
|
||||
|
||||
# Statistics
|
||||
|
||||
## Overview
|
||||
|
||||
Dashboard charts powered by [[Backend]] statistics endpoints and the library store.
|
||||
The Dashboard page shows 7 chart components, combining backend statistics endpoints with client-side library store computations.
|
||||
|
||||
## Charts
|
||||
|
||||
### WatchActivityChart
|
||||
|
||||
- **Type:** Area chart (Recharts)
|
||||
- **Data:** Monthly watch count for a selected year
|
||||
- **Source:** `GET /statistics/watch-count/year/:year` → [[Hooks#useStatistics|useYearlyWatchCount]]
|
||||
- **File:** `components/dashboard/WatchActivityChart.tsx`
|
||||
|
||||
### WatchTimeChart
|
||||
|
||||
- **Type:** Area chart
|
||||
- **Data:** Monthly watch time (hours) for a selected year
|
||||
- **Source:** `GET /statistics/watch-time/year/:year` → [[Hooks#useStatistics|useYearlyWatchTime]]
|
||||
- **File:** `components/dashboard/WatchTimeChart.tsx`
|
||||
|
||||
### CouchDayChart
|
||||
- Shows watch distribution by day of week (bar chart)
|
||||
- Endpoint: `GET /statistics/watch-weekday`
|
||||
- **Only counts records with `accuracy = 'EXACT'`** (Milestone 001)
|
||||
- Queries both `EpisodeSeen` and `EntrySeen` tables
|
||||
|
||||
- **Type:** Bar chart
|
||||
- **Data:** Watch distribution by day of week
|
||||
- **Source:** `GET /statistics/watch-weekday` → [[Hooks#useStatistics|useWatchdayDistribution]]
|
||||
- **File:** `components/dashboard/CouchDayChart.tsx`
|
||||
|
||||
> [!important] Accuracy Filter
|
||||
> Only counts records where `accuracy = 'EXACT'`. Estimated and unknown dates are excluded to prevent skewing day-of-week patterns. See [[Watch Tracking#Accuracy System]].
|
||||
|
||||
**Backend query** (`statisticsController.js`):
|
||||
- Queries both `EpisodeSeen` and `EntrySeen` with `WHERE accuracy = 'EXACT'`
|
||||
- Groups by `DAYOFWEEK(date_seen)` (1=Sunday → 7=Saturday)
|
||||
- Sums counts from both tables
|
||||
|
||||
### LibraryGrowthChart
|
||||
- Shows cumulative library growth over time (area chart)
|
||||
- Data source: Library store entries (client-side computation)
|
||||
- Uses `createdAt` field as the entry date (Milestone 001)
|
||||
- Includes all entries (library + watchlist)
|
||||
- Supports year filter with "All" option
|
||||
|
||||
- **Type:** Area chart
|
||||
- **Data:** Cumulative library growth over time
|
||||
- **Source:** Client-side computation from [[Stores|library store]]
|
||||
- **File:** `components/dashboard/LibraryGrowthChart.tsx`
|
||||
|
||||
Details:
|
||||
|
||||
- Uses `createdAt` field as entry date (when it was added to Showy)
|
||||
- Includes **all entries** (library + watchlist)
|
||||
- Supports year filter dropdown + "All" option
|
||||
- "All" mode: monthly data across all years
|
||||
- Year mode: monthly data for selected year, with cumulative count starting from entries before that year
|
||||
|
||||
### MediaTypeChart
|
||||
|
||||
- **Type:** Chart showing movies vs TV breakdown
|
||||
- **Source:** Client-side from library store
|
||||
- **File:** `components/dashboard/MediaTypeChart.tsx`
|
||||
|
||||
### TopGenresChart
|
||||
|
||||
- **Type:** Chart showing top genres by count
|
||||
- **Source:** Client-side from library store
|
||||
- **File:** `components/dashboard/TopGenresChart.tsx`
|
||||
|
||||
### RatingsChart
|
||||
|
||||
- **Type:** Chart showing ratings distribution
|
||||
- **Source:** Client-side from library store
|
||||
- **File:** `components/dashboard/RatingsChart.tsx`
|
||||
|
||||
## Backend Endpoints
|
||||
|
||||
See [[API Reference#Statistics]].
|
||||
|
||||
| Endpoint | Returns |
|
||||
|---|---|
|
||||
| `GET /statistics/watch-time` | All-time total minutes (series + movies) |
|
||||
| `GET /statistics/watch-time/year/:year` | Monthly watch minutes for year |
|
||||
| `GET /statistics/watch-count/year/:year` | Monthly watch counts for year |
|
||||
| `GET /statistics/watch-weekday` | Day-of-week distribution (EXACT only) |
|
||||
|
||||
## Important Files
|
||||
|
||||
- `react_frontend/src/components/dashboard/CouchDayChart.tsx`
|
||||
- `react_frontend/src/components/dashboard/LibraryGrowthChart.tsx`
|
||||
- `backend/controllers/statisticsController.js` — `getWatchdayDistribution` method
|
||||
| File | Role |
|
||||
|---|---|
|
||||
| `backend/controllers/statisticsController.js` | Backend queries |
|
||||
| `react_frontend/src/components/dashboard/` | All 7 chart components |
|
||||
| `react_frontend/src/hooks/useStatistics.ts` | Query hooks |
|
||||
| `react_frontend/src/api/statistics.ts` | API client |
|
||||
Reference in new issue
Block a user