feat(dashboard): add recharts data visualizations
- Install recharts - Add WatchActivityChart (AreaChart, movies + episodes/month, year filter) - Add WatchTimeChart (stacked BarChart, hours/month, synced year filter) - Add RatingsChart (BarChart, user ratings distribution 1–10, color ramp) - Add TopGenresChart (horizontal BarChart, top 10 genres, type filter) - Add CouchDayChart (BarChart, watch count by weekday, peak day highlight) - Add GET /statistics/watch-weekday backend endpoint (DAYOFWEEK aggregation) - Extend statisticsApi with getYearlyWatchCount, getYearlyWatchTime, getWatchdayDistribution - Add useYearlyWatchCount, useYearlyWatchTime, useWatchdayDistribution hooks - Wire all charts into DashboardPage with responsive two-column grid layout
This commit is contained in:
1 parent
3648c41cfd
commit
ae67663623
12 files changed
+1216
-2
No files matched your search
@@ -120,6 +120,32 @@ class StatisticsController {
|
||||
}
|
||||
}
|
||||
|
||||
async getWatchdayDistribution(req, res) {
|
||||
try {
|
||||
// DAYOFWEEK: 1=Sunday, 2=Monday ... 7=Saturday
|
||||
const episodeDays = await EpisodeSeen.findAll({
|
||||
attributes: [
|
||||
[sequelize.fn('DAYOFWEEK', sequelize.col('date_seen')), 'day'],
|
||||
[sequelize.fn('COUNT', sequelize.col('*')), 'count']
|
||||
],
|
||||
group: [sequelize.fn('DAYOFWEEK', sequelize.col('date_seen'))]
|
||||
});
|
||||
|
||||
const movieDays = await EntrySeen.findAll({
|
||||
attributes: [
|
||||
[sequelize.fn('DAYOFWEEK', sequelize.col('date_seen')), 'day'],
|
||||
[sequelize.fn('COUNT', sequelize.col('*')), 'count']
|
||||
],
|
||||
group: [sequelize.fn('DAYOFWEEK', sequelize.col('date_seen'))]
|
||||
});
|
||||
|
||||
res.status(200).json({ episodes: episodeDays, movies: movieDays });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = new StatisticsController();
|
||||
@@ -13,4 +13,7 @@ statisticsRouter.get('/watch-time/year/:year', statisticsController.getYearlyWat
|
||||
// * GET - Yearly Watch Count Grouped By Month
|
||||
statisticsRouter.get('/watch-count/year/:year', statisticsController.getYearlyWatchCountGroupByMonth);
|
||||
|
||||
// * GET - Watch Day Distribution (DAYOFWEEK)
|
||||
statisticsRouter.get('/watch-weekday', statisticsController.getWatchdayDistribution);
|
||||
|
||||
module.exports = statisticsRouter;
|
||||
Reference in new issue
Block a user