mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Fix total listening time stats check for strings, remove from experimental since listening sessions are created for all playbacks
This commit is contained in:
parent
35f3b5863f
commit
ef88972b25
@ -19,9 +19,9 @@
|
||||
><span class="material-icons pl-2 text-base">content_copy</span>
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="showExperimentalFeatures" class="w-full h-px bg-white bg-opacity-10 my-2" />
|
||||
<div v-if="showExperimentalFeatures" class="py-2">
|
||||
<h1 class="text-lg mb-2 text-white text-opacity-90 px-2 sm:px-0">Listening Stats <span class="pl-2 text-xs text-error">(experimental)</span></h1>
|
||||
<div class="w-full h-px bg-white bg-opacity-10 my-2" />
|
||||
<div class="py-2">
|
||||
<h1 class="text-lg mb-2 text-white text-opacity-90 px-2 sm:px-0">Listening Stats</h1>
|
||||
<p class="text-sm text-gray-300">
|
||||
Total Time Listened:
|
||||
<span class="font-mono text-base">{{ listeningTimePretty }}</span>
|
||||
@ -55,7 +55,9 @@
|
||||
<p>{{ item.media && item.media.metadata ? item.media.metadata.title : 'Unknown' }}</p>
|
||||
<p v-if="item.media && item.media.metadata && item.media.metadata.authorName" class="text-white text-opacity-50 text-sm font-sans">by {{ item.media.metadata.authorName }}</p>
|
||||
</td>
|
||||
<td class="text-center">{{ Math.floor(item.progress * 100) }}%</td>
|
||||
<td class="text-center">
|
||||
<p class="text-sm">{{ Math.floor(item.progress * 100) }}%</p>
|
||||
</td>
|
||||
<td class="text-center hidden sm:table-cell">
|
||||
<ui-tooltip v-if="item.startedAt" direction="top" :text="$formatDate(item.startedAt, 'MMMM do, yyyy HH:mm')">
|
||||
<p class="text-sm">{{ $dateDistanceFromNow(item.startedAt) }}</p>
|
||||
|
@ -305,30 +305,35 @@ class ApiRouter {
|
||||
recentSessions: listeningSessions.slice(0, 10)
|
||||
}
|
||||
listeningSessions.forEach((s) => {
|
||||
var sessionTimeListening = s.timeListening
|
||||
if (typeof sessionTimeListening == 'string') {
|
||||
sessionTimeListening = Number(sessionTimeListening)
|
||||
}
|
||||
|
||||
if (s.dayOfWeek) {
|
||||
if (!listeningStats.dayOfWeek[s.dayOfWeek]) listeningStats.dayOfWeek[s.dayOfWeek] = 0
|
||||
listeningStats.dayOfWeek[s.dayOfWeek] += s.timeListening
|
||||
listeningStats.dayOfWeek[s.dayOfWeek] += sessionTimeListening
|
||||
}
|
||||
if (s.date && s.timeListening > 0) {
|
||||
if (s.date && sessionTimeListening > 0) {
|
||||
if (!listeningStats.days[s.date]) listeningStats.days[s.date] = 0
|
||||
listeningStats.days[s.date] += s.timeListening
|
||||
listeningStats.days[s.date] += sessionTimeListening
|
||||
|
||||
if (s.date === today) {
|
||||
listeningStats.today += s.timeListening
|
||||
listeningStats.today += sessionTimeListening
|
||||
}
|
||||
}
|
||||
if (!listeningStats.items[s.libraryItemId]) {
|
||||
listeningStats.items[s.libraryItemId] = {
|
||||
id: s.libraryItemId,
|
||||
timeListening: s.timeListening,
|
||||
timeListening: sessionTimeListening,
|
||||
mediaMetadata: s.mediaMetadata,
|
||||
lastUpdate: s.lastUpdate
|
||||
}
|
||||
} else {
|
||||
listeningStats.items[s.libraryItemId].timeListening += s.timeListening
|
||||
listeningStats.items[s.libraryItemId].timeListening += sessionTimeListening
|
||||
}
|
||||
|
||||
listeningStats.totalTime += s.timeListening
|
||||
listeningStats.totalTime += sessionTimeListening
|
||||
})
|
||||
return listeningStats
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user