From 08d7a9aa143fb7712adbf55f552af425252a3484 Mon Sep 17 00:00:00 2001 From: mfcar Date: Sun, 19 Feb 2023 21:39:28 +0000 Subject: [PATCH 1/2] Add size stats --- client/pages/config/library-stats.vue | 28 ++++++++++++++++++++++++- client/strings/en-us.json | 3 ++- server/controllers/LibraryController.js | 4 +++- server/utils/libraryHelpers.js | 15 ++++++++++++- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/client/pages/config/library-stats.vue b/client/pages/config/library-stats.vue index 7a926e73..aa4200dc 100644 --- a/client/pages/config/library-stats.vue +++ b/client/pages/config/library-stats.vue @@ -60,6 +60,25 @@ +
+

{{ $strings.HeaderStatsLargestItems }}

+

{{ $strings.MessageNoItems }}

+ +
@@ -105,6 +124,13 @@ export default { if (!this.top10LongestItems.length) return 0 return this.top10LongestItems[0].duration }, + top10LargestItems() { + return this.libraryStats ? this.libraryStats.largestItems || [] : [] + }, + largestItemSize() { + if (!this.top10LargestItems.length) return 0 + return this.top10LargestItems[0].size + }, authorsWithCount() { return this.libraryStats ? this.libraryStats.authorsWithCount : [] }, @@ -135,4 +161,4 @@ export default { this.init() } } - \ No newline at end of file + diff --git a/client/strings/en-us.json b/client/strings/en-us.json index ecbd7f32..aba99d1c 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "General", "HeaderSettingsScanner": "Scanner", "HeaderSleepTimer": "Sleep Timer", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Longest Items (hrs)", "HeaderStatsMinutesListeningChart": "Minutes Listening (last 7 days)", "HeaderStatsRecentSessions": "Recent Sessions", @@ -615,4 +616,4 @@ "ToastSocketFailedToConnect": "Socket failed to connect", "ToastUserDeleteFailed": "Failed to delete user", "ToastUserDeleteSuccess": "User deleted" -} \ No newline at end of file +} diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index d09d52d4..ece93ca2 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -637,6 +637,7 @@ class LibraryController { var authorsWithCount = libraryHelpers.getAuthorsWithCount(libraryItems) var genresWithCount = libraryHelpers.getGenresWithCount(libraryItems) var durationStats = libraryHelpers.getItemDurationStats(libraryItems) + var sizeStats = libraryHelpers.getItemSizeStats(libraryItems) var stats = { totalItems: libraryItems.length, totalAuthors: Object.keys(authorsWithCount).length, @@ -645,6 +646,7 @@ class LibraryController { longestItems: durationStats.longestItems, numAudioTracks: durationStats.numAudioTracks, totalSize: libraryHelpers.getLibraryItemsTotalSize(libraryItems), + largestItems: sizeStats.largestItems, authorsWithCount, genresWithCount } @@ -755,4 +757,4 @@ class LibraryController { next() } } -module.exports = new LibraryController() \ No newline at end of file +module.exports = new LibraryController() diff --git a/server/utils/libraryHelpers.js b/server/utils/libraryHelpers.js index 93d23466..5bbee2af 100644 --- a/server/utils/libraryHelpers.js +++ b/server/utils/libraryHelpers.js @@ -280,6 +280,19 @@ module.exports = { } }, + getItemSizeStats(libraryItems) { + var sorted = sort(libraryItems).desc(li => li.media.size) + var top10 = sorted.slice(0, 10).map(li => ({ id: li.id, title: li.media.metadata.title, size: li.media.size })).filter(i => i.size > 0) + var totalSize = 0 + libraryItems.forEach((li) => { + totalSize += li.media.size + }) + return { + totalSize, + largestItems: top10 + } + }, + getLibraryItemsTotalSize(libraryItems) { var totalSize = 0 libraryItems.forEach((li) => { @@ -843,4 +856,4 @@ module.exports = { return Object.values(albums) } -} \ No newline at end of file +} From 505e0eb3a2b6da3e70638abd63149f58dedd7428 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 20 Feb 2023 17:41:26 -0600 Subject: [PATCH 2/2] Update translations --- client/strings/de.json | 1 + client/strings/es.json | 1 + client/strings/fr.json | 3 ++- client/strings/hr.json | 1 + client/strings/it.json | 1 + client/strings/pl.json | 1 + client/strings/ru.json | 1 + client/strings/zh-cn.json | 1 + 8 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/strings/de.json b/client/strings/de.json index 96b2863d..f938d281 100644 --- a/client/strings/de.json +++ b/client/strings/de.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Allgemein", "HeaderSettingsScanner": "Scanner", "HeaderSleepTimer": "Einschlaf-Timer", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Längste Einträge (h)", "HeaderStatsMinutesListeningChart": "Hörminuten (letzte 7 Tage)", "HeaderStatsRecentSessions": "Neueste Ereignisse", diff --git a/client/strings/es.json b/client/strings/es.json index ecbd7f32..ba435f0b 100644 --- a/client/strings/es.json +++ b/client/strings/es.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "General", "HeaderSettingsScanner": "Scanner", "HeaderSleepTimer": "Sleep Timer", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Longest Items (hrs)", "HeaderStatsMinutesListeningChart": "Minutes Listening (last 7 days)", "HeaderStatsRecentSessions": "Recent Sessions", diff --git a/client/strings/fr.json b/client/strings/fr.json index 6b782cdf..b2006104 100644 --- a/client/strings/fr.json +++ b/client/strings/fr.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Général", "HeaderSettingsScanner": "Scanneur", "HeaderSleepTimer": "Minuterie", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Articles les plus long (heures)", "HeaderStatsMinutesListeningChart": "Minutes d'écoute (7 derniers jours)", "HeaderStatsRecentSessions": "Sessions récentes", @@ -615,4 +616,4 @@ "ToastSocketFailedToConnect": "Échec de la connexion WebSocket", "ToastUserDeleteFailed": "Échec de la suppression de l'utilisateur", "ToastUserDeleteSuccess": "Utilisateur supprimé" -} +} \ No newline at end of file diff --git a/client/strings/hr.json b/client/strings/hr.json index 697e0d6d..467412f2 100644 --- a/client/strings/hr.json +++ b/client/strings/hr.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Opčenito", "HeaderSettingsScanner": "Scanner", "HeaderSleepTimer": "Sleep Timer", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Najduže stavke (sati)", "HeaderStatsMinutesListeningChart": "Minuta odslušanih (posljednjih 7 dana)", "HeaderStatsRecentSessions": "Nedavne sesije", diff --git a/client/strings/it.json b/client/strings/it.json index 4401cc45..90e95b33 100644 --- a/client/strings/it.json +++ b/client/strings/it.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Generale", "HeaderSettingsScanner": "Scanner", "HeaderSleepTimer": "Sveglia", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "libri più lunghi (ore)", "HeaderStatsMinutesListeningChart": "Minuti ascoltati (Ultimi 7 Giorni)", "HeaderStatsRecentSessions": "Sessioni Recenti", diff --git a/client/strings/pl.json b/client/strings/pl.json index 2fb7b14a..497d9ca2 100644 --- a/client/strings/pl.json +++ b/client/strings/pl.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Ogólne", "HeaderSettingsScanner": "Skanowanie", "HeaderSleepTimer": "Wyłącznik czasowy", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Najdłuższe pozycje (hrs)", "HeaderStatsMinutesListeningChart": "Czas słuchania w minutach (ostatnie 7 dni)", "HeaderStatsRecentSessions": "Ostatnie sesje", diff --git a/client/strings/ru.json b/client/strings/ru.json index 3a1cc4b6..07a47627 100644 --- a/client/strings/ru.json +++ b/client/strings/ru.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "Основные", "HeaderSettingsScanner": "Сканер", "HeaderSleepTimer": "Таймер Сна", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "Самые Длинные Книги (часов)", "HeaderStatsMinutesListeningChart": "Минут прослушивания (последние 7 дней)", "HeaderStatsRecentSessions": "Последние Сеансы", diff --git a/client/strings/zh-cn.json b/client/strings/zh-cn.json index cc6581bc..2033feab 100644 --- a/client/strings/zh-cn.json +++ b/client/strings/zh-cn.json @@ -138,6 +138,7 @@ "HeaderSettingsGeneral": "通用", "HeaderSettingsScanner": "扫描", "HeaderSleepTimer": "睡眠计时", + "HeaderStatsLargestItems": "Largest Items", "HeaderStatsLongestItems": "项目时长(小时)", "HeaderStatsMinutesListeningChart": "收听分钟数(最近7天)", "HeaderStatsRecentSessions": "历史会话",