mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Fix playlist deletion
This commit is contained in:
parent
3bb7fbb2f1
commit
e1219cbdef
1 changed files with 13 additions and 5 deletions
|
@ -21,13 +21,12 @@ module Invidious::Database::Playlists
|
||||||
PG_DB.exec(request, args: playlist_array)
|
PG_DB.exec(request, args: playlist_array)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this function is a bit special: it will also remove all videos
|
# deletes the given playlist and connected playlist videos
|
||||||
# related to the given playlist ID in the "playlist_videos" table,
|
|
||||||
# in addition to deleting said ID from "playlists".
|
|
||||||
def delete(id : String)
|
def delete(id : String)
|
||||||
|
PlaylistVideos.delete_by_playlist_id(id)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
DELETE FROM playlist_videos * WHERE plid = $1;
|
DELETE FROM playlists *
|
||||||
DELETE FROM playlists * WHERE id = $1
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, id)
|
PG_DB.exec(request, id)
|
||||||
|
@ -207,6 +206,15 @@ module Invidious::Database::PlaylistVideos
|
||||||
PG_DB.exec(request, index)
|
PG_DB.exec(request, index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_by_playlist_id(playlist_id)
|
||||||
|
request = <<-SQL
|
||||||
|
DELETE FROM playlist_videos *
|
||||||
|
WHERE plid = $1;
|
||||||
|
SQL
|
||||||
|
|
||||||
|
PG_DB.exec(request, playlist_id)
|
||||||
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Salect
|
# Salect
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|
Loading…
Reference in a new issue