Add more user-specific charts (#1991)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2025-12-26 12:08:27 -07:00
committed by GitHub
co-authored by acx10
parent ad8904550b
commit 2c1e8a99e3
53 changed files with 3411 additions and 2120 deletions
@@ -19,6 +19,36 @@ export interface ReadingSessionTimelineResponse {
totalDurationSeconds: number;
}
export interface GenreStatsResponse {
genre: string;
bookCount: number;
totalSessions: number;
totalDurationSeconds: number;
averageSessionsPerBook: number;
}
export interface CompletionTimelineResponse {
year: number;
month: number;
totalBooks: number;
statusBreakdown: { [key: string]: number };
finishedBooks: number;
completionRate: number;
}
export interface FavoriteDaysResponse {
dayOfWeek: number;
dayName: string;
sessionCount: number;
totalDurationSeconds: number;
}
export interface PeakHoursResponse {
hourOfDay: number;
sessionCount: number;
totalDurationSeconds: number;
}
@Injectable({
providedIn: 'root'
})
@@ -32,9 +62,51 @@ export class UserStatsService {
);
}
getTimelineForWeek(year: number, week: number): Observable<ReadingSessionTimelineResponse[]> {
getTimelineForWeek(year: number, month: number, week: number): Observable<ReadingSessionTimelineResponse[]> {
return this.http.get<ReadingSessionTimelineResponse[]>(
`${this.readingSessionsUrl}/timeline/week/${year}/${week}`
`${this.readingSessionsUrl}/timeline/week/${year}/${month}/${week}`
);
}
getGenreStats(): Observable<GenreStatsResponse[]> {
return this.http.get<GenreStatsResponse[]>(
`${this.readingSessionsUrl}/stats/genres`
);
}
getCompletionTimelineForYear(year: number): Observable<CompletionTimelineResponse[]> {
return this.http.get<CompletionTimelineResponse[]>(
`${this.readingSessionsUrl}/stats/completion-timeline/year/${year}`
);
}
getFavoriteDays(year?: number, month?: number): Observable<FavoriteDaysResponse[]> {
let params: any = {};
if (year !== undefined && year !== null) {
params.year = year.toString();
}
if (month !== undefined && month !== null) {
params.month = month.toString();
}
return this.http.get<FavoriteDaysResponse[]>(
`${this.readingSessionsUrl}/stats/favorite-days`,
{params}
);
}
getPeakHours(year?: number, month?: number): Observable<PeakHoursResponse[]> {
let params: any = {};
if (year !== undefined && year !== null) {
params.year = year.toString();
}
if (month !== undefined && month !== null) {
params.month = month.toString();
}
return this.http.get<PeakHoursResponse[]>(
`${this.readingSessionsUrl}/stats/peak-hours`,
{params}
);
}
}