From aacf37e32b2367906ed9da246af2705f6f5cc9d9 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 16 Feb 2024 16:16:55 -0600 Subject: [PATCH] Fix:Year in Review crashing when listening session has a null genre #2623 --- server/utils/queries/adminStats.js | 2 +- server/utils/queries/userStats.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/utils/queries/adminStats.js b/server/utils/queries/adminStats.js index f1d64f478b..0c490de42d 100644 --- a/server/utils/queries/adminStats.js +++ b/server/utils/queries/adminStats.js @@ -110,7 +110,7 @@ module.exports = { }) // Filter out bad genres like "audiobook" and "audio book" - const genres = (ls.mediaMetadata.genres || []).filter(g => !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book')) + const genres = (ls.mediaMetadata.genres || []).filter(g => g && !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book')) genres.forEach((genre) => { if (!genreListeningMap[genre]) genreListeningMap[genre] = 0 genreListeningMap[genre] += (ls.timeListening || 0) diff --git a/server/utils/queries/userStats.js b/server/utils/queries/userStats.js index 6fd5d50696..4e4080f8d3 100644 --- a/server/utils/queries/userStats.js +++ b/server/utils/queries/userStats.js @@ -141,7 +141,7 @@ module.exports = { }) // Filter out bad genres like "audiobook" and "audio book" - const genres = (ls.mediaMetadata.genres || []).filter(g => !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book')) + const genres = (ls.mediaMetadata.genres || []).filter(g => g && !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book')) genres.forEach((genre) => { if (!genreListeningMap[genre]) genreListeningMap[genre] = 0 genreListeningMap[genre] += listeningSessionListeningTime