mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
feat(ratings): skip-to-1★ threshold and mix min-rating filter
Add Ratings section under General: manual skip count before setting 1★, and per-axis minimum stars for random mixes/albums (song, album, artist). StarRating shows five stars with selection capped at three; shared max in authStore. Queue filtering via passesMixMinRatings; OpenSubsonic-style entity rating fields on types.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import type { SubsonicSong } from '../api/subsonic';
|
||||
|
||||
export interface MixMinRatingsConfig {
|
||||
enabled: boolean;
|
||||
minSong: number;
|
||||
minAlbum: number;
|
||||
minArtist: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Random (and future album) flows: drop songs that are below per-axis thresholds when enabled.
|
||||
* Song axis uses `userRating` (missing = 0). Album/artist use optional OpenSubsonic-style
|
||||
* fields on the song payload; if a threshold is positive but the value is absent, the song is kept.
|
||||
*/
|
||||
export function passesMixMinRatings(song: SubsonicSong, c: MixMinRatingsConfig): boolean {
|
||||
if (!c.enabled) return true;
|
||||
if (c.minSong > 0 && (song.userRating ?? 0) < c.minSong) return false;
|
||||
if (c.minAlbum > 0) {
|
||||
const r = song.albumUserRating;
|
||||
if (r !== undefined && r < c.minAlbum) return false;
|
||||
}
|
||||
if (c.minArtist > 0) {
|
||||
const r = song.artistUserRating;
|
||||
if (r !== undefined && r < c.minArtist) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user