Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions rust-api/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17888,7 +17888,7 @@ impl DatabasePool {
let mut play_state_conditions = Vec::new();

if config.include_unplayed {
play_state_conditions.push("h.listenduration IS NULL".to_string());
play_state_conditions.push("(h.listenduration IS NULL AND e.completed IS NOT TRUE)".to_string());
println!("Playlist {}: Added unplayed episode filter", playlist_id);
}

Expand Down Expand Up @@ -18027,7 +18027,7 @@ impl DatabasePool {
let mut play_state_conditions = Vec::new();

if config.include_unplayed {
play_state_conditions.push("h.ListenDuration IS NULL".to_string());
play_state_conditions.push("(h.ListenDuration IS NULL AND e.complete IS NOT TRUE)".to_string());
}

if config.include_partially_played {
Expand Down Expand Up @@ -24411,7 +24411,7 @@ impl DatabasePool {
// Play state filters
let mut play_state_conditions = Vec::new();
if playlist.try_get::<bool, _>("includeunplayed")? {
play_state_conditions.push("(h.listenduration IS NULL OR h.listenduration = 0)".to_string());
play_state_conditions.push("(e.completed IS NOT TRUE AND (h.listenduration IS NULL OR h.listenduration = 0))".to_string());
}
if playlist.try_get::<bool, _>("includepartiallyplayed")? {
play_state_conditions.push(
Expand All @@ -24420,7 +24420,7 @@ impl DatabasePool {
}
if playlist.try_get::<bool, _>("includeplayed")? {
play_state_conditions.push(
"(h.listenduration IS NOT NULL AND (h.listenduration >= e.episodeduration * 0.9 OR (e.episodeduration - h.listenduration) <= 30))".to_string()
"(e.completed IS TRUE OR (h.listenduration IS NOT NULL AND (h.listenduration >= e.episodeduration * 0.9 OR (e.episodeduration - h.listenduration) <= 30)))".to_string()
);
}

Expand Down Expand Up @@ -24772,7 +24772,7 @@ impl DatabasePool {

if playlist.try_get::<bool, _>("includeunplayed")? {
// UNPLAYED: No history record OR listen duration is 0 or NULL
play_state_conditions.push("(h.listenduration IS NULL OR h.listenduration = 0)".to_string());
play_state_conditions.push("(e.completed IS NOT TRUE AND (h.listenduration IS NULL OR h.listenduration = 0))".to_string());
debug!("▶️ Including UNPLAYED episodes");
}

Expand All @@ -24787,7 +24787,7 @@ impl DatabasePool {
if playlist.try_get::<bool, _>("includeplayed")? {
// PLAYED: Listen duration >= 90% OR within 30 seconds of end
play_state_conditions.push(
"(h.listenduration IS NOT NULL AND (h.listenduration >= e.episodeduration * 0.9 OR (e.episodeduration - h.listenduration) <= 30))".to_string()
"(e.completed IS TRUE OR (h.listenduration IS NOT NULL AND (h.listenduration >= e.episodeduration * 0.9 OR (e.episodeduration - h.listenduration) <= 30)))".to_string()
);
debug!("✅ Including PLAYED episodes (>=90% or within 30s of end)");
}
Expand Down Expand Up @@ -25010,7 +25010,7 @@ impl DatabasePool {
let mut play_state_conditions = Vec::new();

if playlist.try_get::<bool, _>("IncludeUnplayed")? {
play_state_conditions.push("(h.ListenDuration IS NULL OR h.ListenDuration = 0)".to_string());
play_state_conditions.push("(e.completed IS NOT TRUE AND (h.ListenDuration IS NULL OR h.ListenDuration = 0))".to_string());
debug!("▶️ Including UNPLAYED episodes (MySQL)");
}

Expand All @@ -25023,7 +25023,7 @@ impl DatabasePool {

if playlist.try_get::<bool, _>("IncludePlayed")? {
play_state_conditions.push(
"(h.ListenDuration IS NOT NULL AND (h.ListenDuration >= e.EpisodeDuration * 0.9 OR (e.EpisodeDuration - h.ListenDuration) <= 30))".to_string()
"(e.completed IS TRUE OR (h.ListenDuration IS NOT NULL AND (h.ListenDuration >= e.EpisodeDuration * 0.9 OR (e.EpisodeDuration - h.ListenDuration) <= 30)))".to_string()
);
debug!("✅ Including PLAYED episodes (MySQL)");
}
Expand Down Expand Up @@ -25161,4 +25161,4 @@ pub async fn create_playlist(pool: &DatabasePool, config: &Config, playlist_data
// Standalone delete_playlist function that matches Python API
pub async fn delete_playlist(pool: &DatabasePool, _config: &Config, playlist_data: &crate::models::DeletePlaylistRequest) -> AppResult<()> {
pool.delete_playlist(playlist_data.user_id, playlist_data.playlist_id).await
}
}