mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-24 09:49:24 +02:00
Add:User listening stats page and new library stats
This commit is contained in:
parent
7845e06a24
commit
b80d735750
13 changed files with 326 additions and 120 deletions
|
@ -458,14 +458,15 @@ class ApiController {
|
|||
books: {},
|
||||
days: {},
|
||||
dayOfWeek: {},
|
||||
today: 0
|
||||
today: 0,
|
||||
recentSessions: listeningSessions.slice(0, 10)
|
||||
}
|
||||
listeningSessions.forEach((s) => {
|
||||
if (s.dayOfWeek) {
|
||||
if (!listeningStats.dayOfWeek[s.dayOfWeek]) listeningStats.dayOfWeek[s.dayOfWeek] = 0
|
||||
listeningStats.dayOfWeek[s.dayOfWeek] += s.timeListening
|
||||
}
|
||||
if (s.date) {
|
||||
if (s.date && s.timeListening > 0) {
|
||||
if (!listeningStats.days[s.date]) listeningStats.days[s.date] = 0
|
||||
listeningStats.days[s.date] += s.timeListening
|
||||
|
||||
|
@ -473,8 +474,17 @@ class ApiController {
|
|||
listeningStats.today += s.timeListening
|
||||
}
|
||||
}
|
||||
if (!listeningStats.books[s.audiobookId]) listeningStats.books[s.audiobookId] = 0
|
||||
listeningStats.books[s.audiobookId] += s.timeListening
|
||||
if (!listeningStats.books[s.audiobookId]) {
|
||||
listeningStats.books[s.audiobookId] = {
|
||||
id: s.audiobookId,
|
||||
timeListening: s.timeListening,
|
||||
title: s.audiobookTitle,
|
||||
author: s.audiobookAuthor,
|
||||
lastUpdate: s.lastUpdate
|
||||
}
|
||||
} else {
|
||||
listeningStats.books[s.audiobookId].timeListening += s.timeListening
|
||||
}
|
||||
|
||||
listeningStats.totalTime += s.timeListening
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue