| 4541 | if ( |
| 4542 | normalizedFavorite !== undefined && |
| 4543 | normalizedFavorite !== null && |
| 4544 | normalizedFavorite !== '' && |
| 4545 | normalizedFavorite !== 'all' && |
| 4546 | normalizedFavorite !== 'undefined' && |
| 4547 | normalizedFavorite !== 'null' |
| 4548 | ) { |
| 4549 | if (normalizedFavorite === 'favorited') { |
| 4550 | conditions.push("favorite = 1"); |
| 4551 | } else if (normalizedFavorite === 'not-favorited') { |
| 4552 | conditions.push("(favorite = 0 OR favorite IS NULL)"); |
| 4553 | } |
| 4554 | } |
| 4555 | |
| 4556 | const normalizedRating = |
| 4557 | typeof filters.rating === 'string' ? filters.rating.trim().toLowerCase() : filters.rating; |
| 4558 | if ( |
| 4559 | normalizedRating !== undefined && |
| 4560 | normalizedRating !== null && |
| 4561 | normalizedRating !== '' && |
| 4562 | normalizedRating !== 'all' && |
| 4563 | normalizedRating !== 'undefined' && |
| 4564 | normalizedRating !== 'null' |
| 4565 | ) { |
| 4566 | if (normalizedRating === 'unrated') { |
| 4567 | conditions.push("(rating = 0 OR rating IS NULL)"); |
| 4568 | } else if (/^[1-5]$/.test(String(normalizedRating))) { |
| 4569 | conditions.push("rating = ?"); |
| 4570 | params.push(parseInt(normalizedRating, 10)); |
| 4571 | } |
| 4572 | } |
| 4573 | |
| 4574 | const normalizedRatingMin = |