Signed-off-by: mbrucedogs <mbrucedogs@gmail.com>

This commit is contained in:
mbrucedogs 2025-07-21 12:59:34 -05:00
parent a326500100
commit 9c14125fac
3 changed files with 9 additions and 9 deletions

View File

@ -34,8 +34,8 @@ exports.updateTopPlayedOnHistoryChange = functions.database
if (historySong && historySong.artist && historySong.title) { if (historySong && historySong.artist && historySong.title) {
// Create a unique key based on artist and title (case-insensitive) // Create a unique key based on artist and title (case-insensitive)
// Replace invalid Firebase key characters with underscores // Replace invalid Firebase key characters with underscores
const sanitizedArtist = historySong.artist.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedArtist = String(historySong.artist || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const sanitizedTitle = historySong.title.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedTitle = String(historySong.title || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const key = `${sanitizedArtist}_${sanitizedTitle}`; const key = `${sanitizedArtist}_${sanitizedTitle}`;
if (aggregation[key]) { if (aggregation[key]) {
// Increment count for existing song // Increment count for existing song
@ -107,8 +107,8 @@ exports.recalculateTopPlayed = functions.https.onCall(async (data, context) => {
if (historySong && historySong.artist && historySong.title) { if (historySong && historySong.artist && historySong.title) {
// Create a unique key based on artist and title (case-insensitive) // Create a unique key based on artist and title (case-insensitive)
// Replace invalid Firebase key characters with underscores // Replace invalid Firebase key characters with underscores
const sanitizedArtist = historySong.artist.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedArtist = String(historySong.artist || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const sanitizedTitle = historySong.title.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedTitle = String(historySong.title || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const key = `${sanitizedArtist}_${sanitizedTitle}`; const key = `${sanitizedArtist}_${sanitizedTitle}`;
if (aggregation[key]) { if (aggregation[key]) {
// Increment count for existing song // Increment count for existing song

File diff suppressed because one or more lines are too long

View File

@ -67,8 +67,8 @@ export const updateTopPlayedOnHistoryChange = functions.database
if (historySong && historySong.artist && historySong.title) { if (historySong && historySong.artist && historySong.title) {
// Create a unique key based on artist and title (case-insensitive) // Create a unique key based on artist and title (case-insensitive)
// Replace invalid Firebase key characters with underscores // Replace invalid Firebase key characters with underscores
const sanitizedArtist = historySong.artist.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedArtist = String(historySong.artist || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const sanitizedTitle = historySong.title.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedTitle = String(historySong.title || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const key = `${sanitizedArtist}_${sanitizedTitle}`; const key = `${sanitizedArtist}_${sanitizedTitle}`;
if (aggregation[key]) { if (aggregation[key]) {
@ -153,8 +153,8 @@ export const recalculateTopPlayed = functions.https.onCall(async (data, context)
if (historySong && historySong.artist && historySong.title) { if (historySong && historySong.artist && historySong.title) {
// Create a unique key based on artist and title (case-insensitive) // Create a unique key based on artist and title (case-insensitive)
// Replace invalid Firebase key characters with underscores // Replace invalid Firebase key characters with underscores
const sanitizedArtist = historySong.artist.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedArtist = String(historySong.artist || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const sanitizedTitle = historySong.title.toLowerCase().trim().replace(/[.#$/[\]]/g, '_'); const sanitizedTitle = String(historySong.title || '').toLowerCase().trim().replace(/[.#$/[\]]/g, '_');
const key = `${sanitizedArtist}_${sanitizedTitle}`; const key = `${sanitizedArtist}_${sanitizedTitle}`;
if (aggregation[key]) { if (aggregation[key]) {